Class: OpenEHR::RM::DataStructures::ItemStructure::ItemList

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 = {}) ⇒ ItemList

Returns a new instance of ItemList.



38
39
40
41
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 38

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

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



36
37
38
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 36

def items
  @items
end

Instance Method Details

#as_hierarchyObject



67
68
69
70
71
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 67

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

#item_countObject



43
44
45
46
47
48
49
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 43

def item_count
  unless @items.nil?
    return @items.size
  else
    return 0
  end
end

#ith_item(i) ⇒ Object

Raises:

  • (ArgumentError)


62
63
64
65
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 62

def ith_item(i)
  raise ArgumentError, 'index invalid' if i <= 0
  return @items[i - 1]
end

#named_item(a_name) ⇒ Object



55
56
57
58
59
60
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 55

def named_item(a_name)
  @items.each do |item|
    return item if item.name.value == a_name
  end
  return nil
end

#namesObject



51
52
53
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 51

def names
  return @items.collect{|item| item.name}
end