Class: Bahn::RoutePart
- Inherits:
-
Object
- Object
- Bahn::RoutePart
- Defined in:
- lib/bahn/bahn_routepart.rb
Overview
Example: “Am 2013-02-01 von 17:33 bis 17:47 : Heerdter Sandberg U, Düsseldorf nach Düsseldorf Hauptbahnhof via U 7”
Instance Attribute Summary collapse
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#price ⇒ Object
Returns the value of attribute price.
-
#start ⇒ Object
Returns the value of attribute start.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#to_s ⇒ Object
Return a nicely formatted route Raises errors if not everything is set properly.
- #transport_type ⇒ Object
Instance Attribute Details
#end_time ⇒ Object
Returns the value of attribute end_time.
7 8 9 |
# File 'lib/bahn/bahn_routepart.rb', line 7 def end_time @end_time end |
#price ⇒ Object
Returns the value of attribute price.
7 8 9 |
# File 'lib/bahn/bahn_routepart.rb', line 7 def price @price end |
#start ⇒ Object
Returns the value of attribute start.
7 8 9 |
# File 'lib/bahn/bahn_routepart.rb', line 7 def start @start end |
#start_time ⇒ Object
Returns the value of attribute start_time.
7 8 9 |
# File 'lib/bahn/bahn_routepart.rb', line 7 def start_time @start_time end |
#target ⇒ Object
Returns the value of attribute target.
7 8 9 |
# File 'lib/bahn/bahn_routepart.rb', line 7 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
7 8 9 |
# File 'lib/bahn/bahn_routepart.rb', line 7 def type @type end |
Instance Method Details
#to_s ⇒ Object
Return a nicely formatted route Raises errors if not everything is set properly
11 12 13 |
# File 'lib/bahn/bahn_routepart.rb', line 11 def to_s "Am #{start_time.to_date} von #{start_time.to_formatted_s :time} bis #{end_time.to_date.to_s + ' ' if end_time.to_date != start_time.to_date}#{end_time.to_formatted_s :time} : #{start} nach #{target} via #{type}" end |
#transport_type ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bahn/bahn_routepart.rb', line 20 def transport_type short_type = self.type.split.first.downcase if ["str", "u", "s", "re", "erb", "ic", "ice"].include? short_type return :train elsif ["bus", "ne"].include? short_type return :bus elsif "Fußweg" == short_type return :foot end # nothing else works self.type end |