class XeroGateway::Report::Row
Constants
- COLUMN_METHOD_NAME_RE
Attributes
section_name[RW]
Public Class Methods
new(column_titles, columns, section_name = nil)
click to toggle source
# File lib/xero_gateway/report/row.rb, line 8 def initialize(column_titles, columns, section_name = nil) @columns = columns @column_titles = column_titles @column_titles_underscored = column_titles.map(&:to_s).map(&:underscore) @section_name = section_name end
Public Instance Methods
[](key)
click to toggle source
# File lib/xero_gateway/report/row.rb, line 15 def [](key) return @columns[key] if key.is_a?(Integer) [ @column_titles, @column_titles_underscored ].each do |names| if index = names.index(key.to_s) return @columns[index] end end nil end
inspect()
click to toggle source
# File lib/xero_gateway/report/row.rb, line 43 def inspect "<XeroGateway::Report::Row:#{object_id} #{pairs}>" end
method_missing(method_name, *args, &block)
click to toggle source
Calls superclass method
# File lib/xero_gateway/report/row.rb, line 27 def method_missing(method_name, *args, &block) if method_name =~ COLUMN_METHOD_NAME_RE # support column_#{n} style deprecated API ActiveSupport::Deprecation.warn("XeroGateway: The #column_n API for accessing report cells will be deprecated in a future version. Please use the underscored column title, a hash or array index accessor", caller_locations) @columns[$1.to_i - 1] elsif (column_index = @column_titles_underscored.index(method_name.to_s)) @columns[column_index] else super end end
respond_to_missing?(method_name, *args)
click to toggle source
Calls superclass method
# File lib/xero_gateway/report/row.rb, line 39 def respond_to_missing?(method_name, *args) (method_name =~ COLUMN_METHOD_NAME_RE) || @column_titles_underscored.include?(method_name.to_s) || super end
Private Instance Methods
pairs()
click to toggle source
# File lib/xero_gateway/report/row.rb, line 49 def pairs @column_titles.zip(@columns).map do |title, value| "#{title.to_s.underscore}: #{value.inspect}" end.join(" ") end