Class: ChronicTree::Command::AddChildElementsToNewAncestors

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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_elementsObject (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_ancestorsObject (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

#sourceObject (readonly)

Returns the value of attribute source.



73
74
75
# File 'lib/chronic_tree/command.rb', line 73

def source
  @source
end

#source_root_idObject (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

#doObject



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