class OpenEHR::RM::DataStructures::ItemStructure::ItemTable
Attributes
rows[RW]
Public Class Methods
new(args = {})
click to toggle source
Calls superclass method
OpenEHR::RM::DataStructures::DataStructure::new
# File lib/openehr/rm/data_structures/item_structure.rb, line 78 def initialize(args = {}) super(args) self.rows = args[:rows] end
Public Instance Methods
as_hierarchy()
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 180 def as_hierarchy return @rows[0] end
column_count()
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 91 def column_count if @rows.nil? return 0 else return @rows[0].items.count end end
column_names()
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 107 def column_names if @rows.nil? return [] else return @rows[0].items.collect{|i| i.name} end end
element_at_cell_ij(i,j)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 163 def element_at_cell_ij(i,j) return @rows[i-1].items[j-1] end
element_at_named_cell(row_key, column_key)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 167 def element_at_named_cell(row_key, column_key) i,j=0,0 @rows[0].items.each do |c| break if c.name.value == column_key i+=1 end @rows.each do |row| break if row.name.value == row_key j+=1 end return element_at_cell_ij(i,j) end
has_column_with_name?(key)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 128 def has_column_with_name?(key) raise ArgumentError, 'invalid argument' if key.nil? or key.empty? self.column_names.each do |name| return true if name.value == key end return false end
has_row_with_key?(keys)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 143 def has_row_with_key?(keys) keys.each do |key| @rows.each do |row| return true if row.items[0].name.value == key end end return false end
has_row_with_name?(key)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 120 def has_row_with_name?(key) raise ArgumentError, 'invalid argument' if key.nil? or key.empty? @rows.each do |row| return true if row.items[0].name.value == key end return false end
ith_row(i)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 115 def ith_row(i) raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size return @rows[i - 1] end
named_row(key)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 136 def named_row(key) raise ArgumentError, 'invalid argument' unless has_row_with_name?(key) @rows.each do |row| return row if row.items[0].name.value == key end end
row_count()
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 83 def row_count if @rows.nil? return 0 else return @rows.size end end
row_names()
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 99 def row_names if @rows.nil? return [] else return @rows.collect{|r| r.name} end end
row_with_key(keys)
click to toggle source
# File lib/openehr/rm/data_structures/item_structure.rb, line 152 def row_with_key(keys) unless has_row_with_key?(keys) raise ArgumentError, 'no row for key' end keys.each do |key| @rows.each do |row| return row if row.items[0].name.value == key end end end