Class: Formatters::PrintFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/tramtracker/formatters/print_formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(tramtracker) ⇒ PrintFormatter

Returns a new instance of PrintFormatter.



3
4
5
# File 'lib/tramtracker/formatters/print_formatter.rb', line 3

def initialize(tramtracker)
  @tramtracker = tramtracker
end

Instance Method Details

#reportObject



7
8
9
10
11
12
13
14
15
# File 'lib/tramtracker/formatters/print_formatter.rb', line 7

def report
  puts Time.now.strftime "[%H:%M:%S] Stop #{@tramtracker.stop_id}"
  puts "Retrieving tram information..."
  @tramtracker.get.each do |tram|
    printf "Route %3s arriving in %2s minutes\n",
      tram[:route],
      tram[:minutes]
  end
end