class Tributa::Table

Attributes

rows[R]

Public Class Methods

new(rows) click to toggle source
# File lib/tributa/table.rb, line 7
def initialize(rows)
  @rows = rows
end

Public Instance Methods

as_json() click to toggle source
# File lib/tributa/table.rb, line 19
def as_json
  {
    rows: rows.map(&:as_json)
  }
end
find_all_by(canton:, community:, year:) click to toggle source
# File lib/tributa/table.rb, line 11
def find_all_by(canton:, community:, year:)
  rows.find_all do |row|
    row.canton == canton &&
      row.community == community &&
      row.year == year.to_s
  end
end
to_json() click to toggle source
# File lib/tributa/table.rb, line 25
def to_json
  as_json.to_json
end