Class: OpenEHR::RM::DataStructures::ItemStructure::ItemTree

Inherits:
ItemStructure show all
Defined in:
lib/open_ehr/rm/data_structures/item_structure.rb

Constant Summary

Constants included from Common::Archetyped::LocaterConstants

Common::Archetyped::LocaterConstants::CONTENT_PATH_SEPARATOR, Common::Archetyped::LocaterConstants::CURRENT_TRANSACTION_ID, Common::Archetyped::LocaterConstants::FRAGMENT_SEPARATOR, Common::Archetyped::LocaterConstants::MULTIPART_ID_DELIMITER, Common::Archetyped::LocaterConstants::ORGANIZER_PATH_SEPARATOR

Instance Attribute Summary collapse

Attributes inherited from Common::Archetyped::Locatable

#archetype_details, #archetype_node_id, #feeder_audit, #links, #name, #uid

Attributes inherited from Common::Archetyped::Pathable

#parent

Instance Method Summary collapse

Methods inherited from Common::Archetyped::Locatable

#concept, #is_archetype_root?

Methods inherited from Common::Archetyped::Pathable

#item_at_path, #items_at_path, #path_exists?, #path_of_item, #path_unique?

Constructor Details

#initialize(args = { }) ⇒ ItemTree

Returns a new instance of ItemTree.



189
190
191
192
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 189

def initialize(args ={ })
  super(args)
  self.items = args[:items]
end

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



187
188
189
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 187

def items
  @items
end

Instance Method Details

#as_hierarchyObject



209
210
211
212
213
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 209

def as_hierarchy
  return Cluster.new(:name => @name,
                     :archetype_node_id => @archetype_node_id,
                     :items => @items)
end

#element_at_path(path) ⇒ Object



202
203
204
205
206
207
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 202

def element_at_path(path)
  @items.each do |item|
    return item if item.archetype_node_id == path
  end
  return nil
end

#has_element_path?(path) ⇒ Boolean

Returns:

  • (Boolean)


194
195
196
197
198
199
200
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 194

def has_element_path?(path)
  paths = [ ]
  @items.each do |item|
    paths << item.archetype_node_id
  end
  return paths.include? path
end