Class: Planter::Plot

Inherits:
Object
  • Object
show all
Defined in:
lib/sapling/planter.rb

Overview

In-memory tree

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#branchesObject

The tree, trunk, and branches



12
13
14
# File 'lib/sapling/planter.rb', line 12

def branches
  @branches
end

#treeObject

The tree, trunk, and branches



12
13
14
# File 'lib/sapling/planter.rb', line 12

def tree
  @tree
end

#trunkObject

The tree, trunk, and branches



12
13
14
# File 'lib/sapling/planter.rb', line 12

def trunk
  @trunk
end

Instance Method Details

#edit_branch(branch_no) ⇒ Object

Edit a branch on the tree

Parameters:

  • branch (Integer)

    The number of the branch to be edited.



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sapling/planter.rb', line 32

def edit_branch(branch_no)
  puts "Current Branch:\n"
  Dialogue.display_branch(@branches[branch_no], branch_no, true)
  print "\n[ =EDITING= ](CTRL-C to abort)> "
  STDOUT.flush
  begin
    new_branch = STDIN.gets.to_s
  rescue Interrupt
    puts "\n**Aborting edit**\n\n"
    new_branch = @branches[branch_no]["desc"]
  end
  @branches[branch_no]["desc"] = new_branch
end

#edit_leaf(branch, leaf) ⇒ Object

Edit a leaf on a branch, grasshopper

Parameters:

  • branch (Integer)

    The number of the branch to be edited.

  • leaf (Hash)

    The leaf hash to be edited.



50
51
52
# File 'lib/sapling/planter.rb', line 50

def edit_leaf(branch, leaf)

end

#edit_trunkObject

Edit the trunk of the tree



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/sapling/planter.rb', line 15

def edit_trunk
  puts "Current Trunk:\n"
  Dialogue.display_trunk(@trunk, true)
  print "\n[ =EDITING= ](CTRL-C to abort)> "
  STDOUT.flush
  begin
    new_trunk = STDIN.gets.to_s
  rescue Interrupt
    puts "\n**Aborting edit**\n\n"
    new_trunk = @trunk["trunk"]
  end
  @trunk["trunk"] = new_trunk
end