Class: Cp8Cli::Table::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/cp8_cli/table/row.rb

Constant Summary collapse

COLOR_TRANSLATIONS =
{
  "purple" => "magenta",
  "orange" => "yellow",
  "sky" => "cyan",
  "pink" => "red",
  "lime" => "green"
}

Instance Method Summary collapse

Constructor Details

#initialize(record, index) ⇒ Row

Returns a new instance of Row.



14
15
16
17
# File 'lib/cp8_cli/table/row.rb', line 14

def initialize(record, index)
  @record = record
  @num = index + 1
end

Instance Method Details

#to_hObject



19
20
21
22
23
24
25
# File 'lib/cp8_cli/table/row.rb', line 19

def to_h
  result = { "#": num }
  fields.each do |field|
    result[field] = colorize record.send(field)
  end
  result
end