exe/zvv in zvv-cli-0.1.2 vs exe/zvv in zvv-cli-0.1.3

- old
+ new

@@ -3,30 +3,21 @@ require 'rubygems' require 'commander' require 'transprt' require 'colorize' +require 'debug' require 'zvv/cli' require 'ostruct' require 'time' module Patches refine String do def strftime DateTime.iso8601(self).strftime('%H:%M') end - - def subzh - gsub('Zürich', 'Zh'). - gsub('Bahnhof', 'Bhf') - end - - def subcon - tokens = split(' ') - tokens[0][-1] + ' ' + tokens[1] - end end refine Hash do def to_ostruct OpenStruct.new(self).tap do |o| @@ -77,16 +68,19 @@ date: time.strftime('%Y-%m-%d'), time: time.strftime('%H:%M'), isArrivalTime: isArrivalTime ) + # pp connections[0] + connections.to_ostruct.each_with_index do |c, i| - puts ("%s %s ---> %s %s" % [c.from.station.name, c.from.departure.strftime, c.to.station.name, c.to.arrival.strftime]).subzh + duration_sec = (DateTime.iso8601(c.to.arrival).to_time - DateTime.iso8601(c.from.departure).to_time).to_int + puts ("%-20s %5s %2d:%02d %-20s %5s" % [c.from.station.name, c.from.departure.strftime, duration_sec / 60 ** 2, (duration_sec % 60 ** 2) / 60, c.to.station.name, c.to.arrival.strftime]) c.sections.each do |s| if s.walk - puts ("Walk (%s) to %s" % [s.walk.duration, s.departure.station.name]).subzh.light_black + puts ("Walk (%sm) to %s" % [s.walk.duration, s.departure.station.name]).light_black else - puts ("%s %s -- %s --> %s %s" % [s.departure.station.name, s.departure.departure.strftime, s.journey.name.subcon, s.arrival.station.name, s.arrival.arrival.strftime]).subzh.light_black + puts ("%-20s %5s %2s%-3s %-20s %5s" % [s.departure.station.name, s.departure.departure.strftime, s.journey.category, s.journey.number[0..2], s.arrival.station.name, s.arrival.arrival.strftime]).light_black end end puts unless i == connections.length - 1 end end \ No newline at end of file