Class: Gardner::Digiplot

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

Overview

Digiplot represents a Plot used for editing. The Digiplot functions exactly like a Plot, except with additional functionality for over-writing existing branches, leaves, and the trunk.

Instance Attribute Summary collapse

Attributes inherited from Plot

#branches, #tree, #trunk

Instance Method Summary collapse

Methods inherited from Plot

#prune_branches, #prune_leaves, #prune_trunk

Constructor Details

#initializeDigiplot

Initialize a Digiplot just like a Plot, but also copy the trunk and branches to “old” instance variables.



73
74
75
76
77
# File 'lib/sapling/gardner.rb', line 73

def initialize
  super
  @old_trunk = @trunk
  @old_branches = @branches
end

Instance Attribute Details

#old_branchesObject (readonly)

Duplicate the “old” trunk and branches, for restoration purposes



66
67
68
# File 'lib/sapling/gardner.rb', line 66

def old_branches
  @old_branches
end

#old_trunkObject (readonly)

Duplicate the “old” trunk and branches, for restoration purposes



66
67
68
# File 'lib/sapling/gardner.rb', line 66

def old_trunk
  @old_trunk
end

#trunk=(value) ⇒ Object (writeonly)

Enable editing for the trunk



69
70
71
# File 'lib/sapling/gardner.rb', line 69

def trunk=(value)
  @trunk = value
end

Instance Method Details

#branch=(branch, text) ⇒ Object

Change a branch

Parameters:

  • branch (Integer)

    the number of the branch to be edited



82
83
84
# File 'lib/sapling/gardner.rb', line 82

def branch=(branch, text)
  @branches[branch]['desc'] = text
end

#leaf=(branch, leaf, text, target) ⇒ Object

Change a leaf on a branch, grasshopper

Parameters:

  • branch (Integer)

    the number of the branch to be edited

  • leaf (Integer)

    the number of the leaf to be edited

  • text (String)

    the new text for the leaf

  • target (Integer)

    the branch number target for the leaf option



92
93
94
# File 'lib/sapling/gardner.rb', line 92

def leaf=(branch, leaf, text, target)
  @branches[branch]['options'][leaf] = { text => target }
end