class Tblr::Row

Attributes

headers[RW]
row[RW]

Public Class Methods

new(*args) click to toggle source
# File lib/tblr/row.rb, line 7
def initialize(*args)
  @headers = args[0]
  @row = args[1]
end

Public Instance Methods

==(another_row) click to toggle source
# File lib/tblr/row.rb, line 12
def ==(another_row)
  headers == another_row.headers &&
    row == another_row.row
end
data_for_header(name) click to toggle source
# File lib/tblr/row.rb, line 21
def data_for_header(name)
  idx = :nope
  camel = name.camelize(:lower)
  if headers.include?(name)
    idx = headers.index(name)
  elsif headers.include?(camel)
    idx = headers.index(camel)
  end

  idx == :nope ? :nope : row[idx]
end
method_missing(sym, *args, &block) click to toggle source
Calls superclass method
# File lib/tblr/row.rb, line 33
def method_missing(sym, *args, &block)
  data = data_for_header(sym.to_s)
  data == :nope ? super(sym, *args, &block) : data
end
to_a() click to toggle source
# File lib/tblr/row.rb, line 17
def to_a
  row
end