Class: ChronicTree::Command::AddReplacedObjToOrigAncestors

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, source_ancestors, target) ⇒ AddReplacedObjToOrigAncestors

Returns a new instance of AddReplacedObjToOrigAncestors.



109
110
111
112
113
114
# File 'lib/chronic_tree/command.rb', line 109

def initialize(source, source_root_id, source_ancestors, target)
  @source = source
  @source_root_id = source_root_id
  @source_ancestors = source_ancestors
  @target = target
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source.



107
108
109
# File 'lib/chronic_tree/command.rb', line 107

def source
  @source
end

#source_ancestorsObject (readonly)

Returns the value of attribute source_ancestors.



107
108
109
# File 'lib/chronic_tree/command.rb', line 107

def source_ancestors
  @source_ancestors
end

#source_root_idObject (readonly)

Returns the value of attribute source_root_id.



107
108
109
# File 'lib/chronic_tree/command.rb', line 107

def source_root_id
  @source_root_id
end

#targetObject (readonly)

Returns the value of attribute target.



107
108
109
# File 'lib/chronic_tree/command.rb', line 107

def target
  @target
end

Instance Method Details

#doObject



116
117
118
119
120
# File 'lib/chronic_tree/command.rb', line 116

def do
  source_ancestors.each_with_index do |parent_object, i|
    AddChildElement.new(parent_object, target.id, i + 1, source_root_id).do
  end
end