Class: ChronicTree::Command::AddChildElementsToNewAncestors
- Inherits:
-
Object
- Object
- ChronicTree::Command::AddChildElementsToNewAncestors
- Defined in:
- lib/chronic_tree/command.rb
Instance Attribute Summary collapse
-
#child_elements ⇒ Object
readonly
Returns the value of attribute child_elements.
-
#new_ancestors ⇒ Object
readonly
Returns the value of attribute new_ancestors.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_root_id ⇒ Object
readonly
Returns the value of attribute source_root_id.
Instance Method Summary collapse
- #do ⇒ Object
-
#initialize(source, source_root_id, new_ancestors, child_elements) ⇒ AddChildElementsToNewAncestors
constructor
A new instance of AddChildElementsToNewAncestors.
Constructor Details
#initialize(source, source_root_id, new_ancestors, child_elements) ⇒ AddChildElementsToNewAncestors
Returns a new instance of AddChildElementsToNewAncestors.
75 76 77 78 79 80 |
# File 'lib/chronic_tree/command.rb', line 75 def initialize(source, source_root_id, new_ancestors, child_elements) @source = source @source_root_id = source_root_id @new_ancestors = new_ancestors @child_elements = child_elements end |
Instance Attribute Details
#child_elements ⇒ Object (readonly)
Returns the value of attribute child_elements.
73 74 75 |
# File 'lib/chronic_tree/command.rb', line 73 def child_elements @child_elements end |
#new_ancestors ⇒ Object (readonly)
Returns the value of attribute new_ancestors.
73 74 75 |
# File 'lib/chronic_tree/command.rb', line 73 def new_ancestors @new_ancestors end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
73 74 75 |
# File 'lib/chronic_tree/command.rb', line 73 def source @source end |
#source_root_id ⇒ Object (readonly)
Returns the value of attribute source_root_id.
73 74 75 |
# File 'lib/chronic_tree/command.rb', line 73 def source_root_id @source_root_id end |
Instance Method Details
#do ⇒ Object
82 83 84 85 86 87 88 |
# File 'lib/chronic_tree/command.rb', line 82 def do new_ancestors.each_with_index do |parent_object, i| child_elements.each do |e| AddChildElement.new(parent_object, e.child_id, e.distance + i, source_root_id).do end end end |