Changeset 210


Ignore:
Timestamp:
Aug 17, 2009, 9:54:25 PM (15 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #54

Location:
ruby/branches/0.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ruby/branches/0.5/lib/open_ehr/rm/data_structures/item_structure.rb

    r209 r210  
    150150            return false
    151151          end
     152
     153          def row_with_key(keys)
     154            unless has_row_with_key?(keys)
     155              raise ArgumentError, 'no row for key'
     156            end
     157            keys.each do |key|
     158              @rows.each do |row|
     159                return row if row.items[0].name.value == key
     160              end
     161            end
     162          end
    152163        end
    153164      end # of ItemStructure
  • ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb

    r209 r210  
    105105    @item_table.has_row_with_key?(Set['two','five']).should be_false
    106106  end
     107
     108  it 'should be a first row that has one' do
     109    @item_table.row_with_key(Set['one', 'two']).items[0].name.value.should =='one'
     110  end
     111
     112  it 'should raise argument error if row has no key' do
     113    lambda {
     114      @item_table.row_with_key(Set['two','five'])}.should raise_error(ArgumentError)
     115  end
    107116end
Note: See TracChangeset for help on using the changeset viewer.