caltrain 0.0.7.1 → 0.1

Sign up to get free protection for your applications and to get access to all the features.
data/lib/caltrain.rb CHANGED
@@ -15,7 +15,7 @@ module Caltrain
15
15
 
16
16
  def usage
17
17
  puts "Usage:"
18
- puts " caltrain <location> <direction> [ list | next ]"
18
+ puts " caltrain <location> <direction> [ list | next ] [ --stops ]"
19
19
  puts ""
20
20
  puts "Abbreviations:"
21
21
  pretty_hash(Schedule.abbrevs)
@@ -34,13 +34,14 @@ module Caltrain
34
34
  usage unless loc && dir
35
35
  loc = loc.to_sym
36
36
  act = :next unless act
37
+ detailed = args.include?('--stops')
37
38
 
38
39
  populate_trips!
39
40
 
40
41
  if dir =~ /^n/i
41
- Schedule.method(act).call(loc, :north)
42
+ Schedule.method(act).call(loc, :north, $stdout, detailed)
42
43
  elsif dir =~ /^s/i
43
- Schedule.method(act).call(loc, :south)
44
+ Schedule.method(act).call(loc, :south, $stdout, detailed)
44
45
  else
45
46
  raise("#{dir} is not a recognized direction")
46
47
  end
@@ -2,9 +2,13 @@ module Printing
2
2
  def print_trip(trip, time, options={})
3
3
  start = options[:starting_at]
4
4
  output = options[:output] || $stdout
5
+ detailed = (options[:detailed] == true)
5
6
 
6
7
  output << train_info(trip, time) << "\n"
7
- output << " " << stop_info(trip, start) << "\n"
8
+
9
+ if detailed
10
+ output << " " << stop_info(trip, start) << "\n"
11
+ end
8
12
  end
9
13
 
10
14
  def train_info(trip, time)
@@ -10,17 +10,17 @@ module Schedule
10
10
  @data ||= DataParser.parse(times_path)
11
11
  end
12
12
 
13
- def list(loc, dir, output=$stdout)
13
+ def list(loc, dir, output=$stdout, detailed=false)
14
14
  trips = trips_with_times(loc, dir).select { |_, time| time > now }
15
- options = {:output => output, :starting_at => loc}
15
+ options = {:output => output, :starting_at => loc, :detailed => detailed}
16
16
 
17
17
  trips.each { |trip, time| print_trip(trip, time, options) }
18
18
  end
19
19
 
20
- def next(loc, dir, output=$stdout)
20
+ def next(loc, dir, output=$stdout, detailed=false)
21
21
  trip = trips_with_times(loc, dir).find { |_, time| time > now }
22
22
  raise("No trips found!") unless trip
23
- options = {:output => output, :starting_at => loc}
23
+ options = {:output => output, :starting_at => loc, :detailed => detailed}
24
24
 
25
25
  print_trip(trip.first, trip.last, options)
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caltrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7.1
4
+ version: '0.1'
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: