Changeset 207 for ruby/branches/0.5
- Timestamp:
- Aug 16, 2009, 7:14:16 PM (15 years ago)
- Location:
- ruby/branches/0.5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb
r203 r207 57 57 58 58 def ith_item(i) 59 return @items[i] 59 raise ArgumentError, 'index invalid' if i <= 0 60 return @items[i - 1] 60 61 end 61 62 … … 82 83 end 83 84 end 85 86 def column_count 87 if @rows.nil? 88 return 0 89 else 90 return @rows[0].items.count 91 end 92 end 93 94 def row_names 95 if @rows.nil? 96 return [] 97 else 98 return @rows.collect{|r| r.name} 99 end 100 end 101 102 def column_names 103 if @rows.nil? 104 return [] 105 else 106 return @rows[0].items.collect{|i| i.name} 107 end 108 end 109 110 def ith_row(i) 111 raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size 112 if @rows.nil? 113 return [] 114 else 115 return @rows[i - 1] 116 end 117 end 84 118 end 85 119 end # of ItemStructure -
ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb
r205 r207 40 40 41 41 it 'retrieve the ith item with number' do 42 @item_list.ith_item(1).name.value.should == ' two'42 @item_list.ith_item(1).name.value.should == 'one' 43 43 end 44 44 -
ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb
r206 r207 32 32 end 33 33 34 it ' row count should be 2' do34 it 's row count should be 2' do 35 35 @item_table.row_count.should be_equal 2 36 36 end 37 37 38 it 'column_count should be 3' do 38 it 's row_count should be 0 when rows are nil' do 39 @item_table.rows = nil 40 @item_table.row_count.should be_equal 0 41 end 42 43 it 's column_count should be 3' do 39 44 @item_table.column_count.should be_equal 3 40 45 end 41 46 42 it 'row_names should be cluster cluster' do 47 48 it 's row_names should be cluster cluster' do 43 49 @item_table.row_names.should == %w{cluster cluster}.collect{|n| DvText.new(n)} 44 50 end 51 52 it 's row_names should be empty when items are nil' do 53 @item_table.rows = nil 54 @item_table.row_names.should == [] 55 end 56 57 it 's column_names should one two three' do 58 @item_table.column_names.should == %w{one two three}.collect{|s| DvText.new(s)} 59 end 60 61 it 's column_names should empty when items aer nil' do 62 @item_table.rows = nil 63 @item_table.column_names.should == [] 64 end 65 66 it 's ith_row(integer) should be ith row' do 67 @item_table.ith_row(2).items[1].name.value.should == 'five' 68 end 69 70 it 'should be invalid index under 0' do 71 lambda {@item_table.ith_row(0) }.should raise_error(ArgumentError) 72 end 45 73 end
Note:
See TracChangeset
for help on using the changeset viewer.