Class: Recras::Itinerary
- Inherits:
-
Object
- Object
- Recras::Itinerary
- Extended by:
- Recras
- Defined in:
- lib/recras/itinerary.rb
Overview
links to ‘programma’ in the API recras.github.io/docs/endpoints/arrangementen.html
Constant Summary
Constants included from Recras
Instance Attribute Summary collapse
- #description ⇒ Object
-
#duration ⇒ Object
Returns the value of attribute duration.
-
#end_time ⇒ Object
Returns the value of attribute end_time.
-
#json ⇒ Object
Returns the value of attribute json.
-
#quantity ⇒ Object
Returns the value of attribute quantity.
-
#quantity_type ⇒ Object
Returns the value of attribute quantity_type.
-
#start_time ⇒ Object
Returns the value of attribute start_time.
Class Method Summary collapse
-
.attribute_mapping ⇒ Object
translates the mapping between the Recras API and the terms used in this gem.
- .plural_name ⇒ Object
Instance Method Summary collapse
- #duration_hours ⇒ Object
- #duration_minutes ⇒ Object
- #duration_seconds ⇒ Object
- #duration_string ⇒ Object
-
#initialize(args = nil) ⇒ Itinerary
constructor
Initializer to transform a
Hash
into an Client object. -
#to_s ⇒ Object
outputs a nice readable itinerary.
Methods included from Recras
make_request, new_from_json, object_mappings, parse_json, url, version
Constructor Details
#initialize(args = nil) ⇒ Itinerary
Initializer to transform a Hash
into an Client object
19 20 21 22 23 24 25 |
# File 'lib/recras/itinerary.rb', line 19 def initialize(args=nil) required_args = [] return if args.nil? args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Attribute Details
#description ⇒ Object
The is a required parameter.
9 10 11 |
# File 'lib/recras/itinerary.rb', line 9 def description @description end |
#duration ⇒ Object
Returns the value of attribute duration.
14 15 16 |
# File 'lib/recras/itinerary.rb', line 14 def duration @duration end |
#end_time ⇒ Object
Returns the value of attribute end_time.
13 14 15 |
# File 'lib/recras/itinerary.rb', line 13 def end_time @end_time end |
#json ⇒ Object
Returns the value of attribute json.
15 16 17 |
# File 'lib/recras/itinerary.rb', line 15 def json @json end |
#quantity ⇒ Object
Returns the value of attribute quantity.
10 11 12 |
# File 'lib/recras/itinerary.rb', line 10 def quantity @quantity end |
#quantity_type ⇒ Object
Returns the value of attribute quantity_type.
11 12 13 |
# File 'lib/recras/itinerary.rb', line 11 def quantity_type @quantity_type end |
#start_time ⇒ Object
Returns the value of attribute start_time.
12 13 14 |
# File 'lib/recras/itinerary.rb', line 12 def start_time @start_time end |
Class Method Details
.attribute_mapping ⇒ Object
translates the mapping between the Recras API and the terms used in this gem
65 66 67 |
# File 'lib/recras/itinerary.rb', line 65 def self.attribute_mapping [["omschrijving", "description"], ["aantal", "quantity"], ["wat", "quantity_type"], ["begin", "start_time"], ["duur", "duration"], ["eind", "end_time"]] end |
.plural_name ⇒ Object
59 60 61 |
# File 'lib/recras/itinerary.rb', line 59 def self.plural_name "itineraries" end |
Instance Method Details
#duration_hours ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/recras/itinerary.rb', line 36 def duration_hours begin duration.split("PT").last.split("H").first.to_i rescue nil end end |
#duration_minutes ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/recras/itinerary.rb', line 44 def duration_minutes begin duration.split("H").last.split("M").first.to_i rescue nil end end |
#duration_seconds ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/recras/itinerary.rb', line 52 def duration_seconds begin duration.split("M").last.split("S").first.to_i rescue nil end end |
#duration_string ⇒ Object
32 33 34 |
# File 'lib/recras/itinerary.rb', line 32 def duration_string "#{duration_hours.to_s.rjust(2, '0')}:#{duration_minutes.to_s.rjust(2, '0')}:#{duration_seconds.to_s.rjust(2, '0')}" end |
#to_s ⇒ Object
outputs a nice readable itinerary
28 29 30 |
# File 'lib/recras/itinerary.rb', line 28 def to_s "#{description} - #{quantity} #{quantity_type} (#{duration_string})" end |