Class: SpreeCmCommissioner::Integrations::BookMeBusV1::Resources::Stop
- Defined in:
- app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
Returns the value of attribute address.
-
#code ⇒ Object
Returns the value of attribute code.
-
#description ⇒ Object
Returns the value of attribute description.
-
#id ⇒ Object
Returns the value of attribute id.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#location ⇒ Object
Returns the value of attribute location.
-
#location_id ⇒ Object
Returns the value of attribute location_id.
-
#lon ⇒ Object
Returns the value of attribute lon.
-
#name ⇒ Object
Returns the value of attribute name.
-
#operator_branch_id ⇒ Object
Returns the value of attribute operator_branch_id.
-
#operator_id ⇒ Object
Returns the value of attribute operator_id.
-
#place_type ⇒ Object
Returns the value of attribute place_type.
-
#shared ⇒ Object
Returns the value of attribute shared.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#type ⇒ Object
Returns the value of attribute type.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#branch? ⇒ Boolean
A branch is an operator’s physical terminal (operator_branch_id != 0) A stop is a general pickup/drop-off point (operator_branch_id == 0).
-
#initialize(attributes = {}) ⇒ Stop
constructor
A new instance of Stop.
- #latitude ⇒ Object
- #location_name ⇒ Object
- #longitude ⇒ Object
- #stop? ⇒ Boolean
- #to_h ⇒ Object
-
#unique_external_id ⇒ Object
Returns the unique identifier for this stop/branch For branches, use operator_branch_id to avoid duplicates For stops, use the stop id.
- #vendor_place_type ⇒ Object
Methods inherited from Base
from_json_api, from_json_api_item, from_json_api_single
Constructor Details
#initialize(attributes = {}) ⇒ Stop
Returns a new instance of Stop.
20 21 22 23 24 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 20 def initialize(attributes = {}) super(attributes) @location = Location.new(attributes['location']) if attributes['location'].is_a?(Hash) end |
Instance Attribute Details
#address ⇒ Object
Returns the value of attribute address.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def address @address end |
#code ⇒ Object
Returns the value of attribute code.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def code @code end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def description @description end |
#id ⇒ Object
Returns the value of attribute id.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def id @id end |
#lat ⇒ Object
Returns the value of attribute lat.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def lat @lat end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def location @location end |
#location_id ⇒ Object
Returns the value of attribute location_id.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def location_id @location_id end |
#lon ⇒ Object
Returns the value of attribute lon.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def lon @lon end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def name @name end |
#operator_branch_id ⇒ Object
Returns the value of attribute operator_branch_id.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def operator_branch_id @operator_branch_id end |
#operator_id ⇒ Object
Returns the value of attribute operator_id.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def operator_id @operator_id end |
#place_type ⇒ Object
Returns the value of attribute place_type.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def place_type @place_type end |
#shared ⇒ Object
Returns the value of attribute shared.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def shared @shared end |
#timezone ⇒ Object
Returns the value of attribute timezone.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def timezone @timezone end |
#type ⇒ Object
Returns the value of attribute type.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def type @type end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 3 def url @url end |
Instance Method Details
#branch? ⇒ Boolean
A branch is an operator’s physical terminal (operator_branch_id != 0) A stop is a general pickup/drop-off point (operator_branch_id == 0)
40 41 42 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 40 def branch? operator_branch_id.to_i != 0 end |
#latitude ⇒ Object
26 27 28 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 26 def latitude lat.to_f end |
#location_name ⇒ Object
34 35 36 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 34 def location_name location&.name end |
#longitude ⇒ Object
30 31 32 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 30 def longitude lon.to_f end |
#stop? ⇒ Boolean
44 45 46 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 44 def stop? !branch? end |
#to_h ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 63 def to_h { id: id, type: type, code: code, name: name, lat: lat, lon: lon, description: description, timezone: timezone, url: url, place_type: place_type, shared: shared, operator_id: operator_id, operator_branch_id: operator_branch_id, location_id: location_id, address: address, location: location&.to_h }.compact end |
#unique_external_id ⇒ Object
Returns the unique identifier for this stop/branch For branches, use operator_branch_id to avoid duplicates For stops, use the stop id
55 56 57 58 59 60 61 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 55 def unique_external_id if branch? "branch-#{operator_branch_id}" else "stop-#{id}" end end |
#vendor_place_type ⇒ Object
48 49 50 |
# File 'app/services/spree_cm_commissioner/integrations/book_me_bus_v1/resources/stop.rb', line 48 def vendor_place_type branch? ? :branch : :stop end |