Class: Printer

Inherits:
Object
  • Object
show all
Defined in:
lib/teecket/printer.rb

Class Method Summary collapse

Class Method Details

.table(rows = []) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/teecket/printer.rb', line 4

def self.table(rows = [])
  headings = [
    "Flight",
    "Flight #",
    "Transit",
    "Origin",
    "Destination",
    "Depart",
    "Arrive",
    "Fare (RM)"]

  rows.each { |row| row[:fare] = row[:fare].rjust(9, " ") }

  rows.map!(&:values)

  Terminal::Table.new(headings: headings, rows: rows)
end