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.



40
41
42
43
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 40

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

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



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

def items
  @items
end

Instance Method Details

#as_hierarchyObject



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

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

#item_countObject



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

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

#ith_item(i) ⇒ Object

Raises:

  • (ArgumentError)


64
65
66
67
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 64

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

#named_item(a_name) ⇒ Object



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

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

#namesObject



53
54
55
# File 'lib/open_ehr/rm/data_structures/item_structure.rb', line 53

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