Class: ChronicTree::Command::AddChildElementToOrigAncestors

Inherits:
Object
  • Object
show all
Defined in:
lib/chronic_tree/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, child) ⇒ AddChildElementToOrigAncestors

Returns a new instance of AddChildElementToOrigAncestors.



94
95
96
97
# File 'lib/chronic_tree/command.rb', line 94

def initialize(source, child)
  @source = source
  @child = child
end

Instance Attribute Details

#childObject (readonly)

Returns the value of attribute child.



92
93
94
# File 'lib/chronic_tree/command.rb', line 92

def child
  @child
end

#sourceObject (readonly)

Returns the value of attribute source.



92
93
94
# File 'lib/chronic_tree/command.rb', line 92

def source
  @source
end

Instance Method Details

#doObject



99
100
101
102
103
# File 'lib/chronic_tree/command.rb', line 99

def do
  source.ancestors.each_with_index do |parent_object, index|
    AddChildElement.new(parent_object, child, index + 2, source.root.id).do
  end
end