source: ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb@ 203

Last change on this file since 203 was 203, checked in by KOBAYASHI, Shinji, 15 years ago

refs #54

File size: 2.0 KB
Line 
1# rm::data_structures::item_structure
2# ItemStructure module
3# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109346709572_859750_3810Report.html
4# refs #54
5include OpenEhr::RM::DataStructures
6module OpenEhr
7 module RM
8 module DataStructures
9 module ItemStructure
10 class ItemStructure < DataStructure
11 end
12
13 class ItemSingle < ItemStructure
14 attr_reader :item
15
16 def initialize(args = {})
17 super(args)
18 self.item = args[:item]
19 end
20
21 def as_hierarchy
22 return @item
23 end
24
25 def item=(item)
26 raise ArgumentError, 'item is mandatory' if item.nil?
27 @item = item
28 end
29 end
30
31 class ItemList < ItemStructure
32 attr_accessor :items
33
34 def initialize(args = {})
35 super(args)
36 self.items = args[:items]
37 end
38
39 def item_count
40 unless @items.nil?
41 return @items.size
42 else
43 return 0
44 end
45 end
46
47 def names
48 return @items.collect{|item| item.name}
49 end
50
51 def named_item(a_name)
52 @items.each do |item|
53 return item if item.name.value == a_name
54 end
55 retrun nil
56 end
57
58 def ith_item(i)
59 return @items[i]
60 end
61
62 def as_hierarchy
63 return Cluster.new(:name => @name,
64 :archetype_node_id => @archetype_node_id,
65 :items => @items)
66 end
67 end
68
69 class ItemTable < ItemStructure
70 attr_accessor :rows
71
72 def initialize(args = {})
73 super(args)
74 self.rows = args[:rows]
75 end
76
77 def row_count
78 if @rows.nil?
79 return 0
80 else
81 return @rows.size
82 end
83 end
84 end
85 end # of ItemStructure
86 end # of DataStructures
87 end # of RM
88end # of OpenEhr
Note: See TracBrowser for help on using the repository browser.