Class: SpreeCmCommissioner::Integrations::Larryta::Resources::Direction
- Inherits:
-
Base
- Object
- Base
- SpreeCmCommissioner::Integrations::Larryta::Resources::Direction
- Defined in:
- app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb
Overview
Represents a direction/route from Larryta API
Instance Attribute Summary collapse
-
#direction_code ⇒ Object
Returns the value of attribute direction_code.
-
#direction_id ⇒ Object
Returns the value of attribute direction_id.
-
#from_location_id ⇒ Object
Returns the value of attribute from_location_id.
-
#from_location_name ⇒ Object
Returns the value of attribute from_location_name.
-
#from_location_name_kh ⇒ Object
Returns the value of attribute from_location_name_kh.
-
#to_location_id ⇒ Object
Returns the value of attribute to_location_id.
-
#to_location_name ⇒ Object
Returns the value of attribute to_location_name.
-
#to_location_name_kh ⇒ Object
Returns the value of attribute to_location_name_kh.
-
#travel_time ⇒ Object
Returns the value of attribute travel_time.
Instance Method Summary collapse
-
#display_name ⇒ Object
Returns the display name for this direction.
-
#display_name_kh ⇒ Object
Returns the Khmer display name.
-
#from_location_data ⇒ Object
Returns the from location data in the format expected by sync_location!.
-
#id ⇒ Object
Returns the direction ID.
-
#initialize(data) ⇒ Direction
constructor
rubocop:disable Lint/MissingSuper.
-
#to_h ⇒ Object
Returns a hash representation.
-
#to_location_data ⇒ Object
Returns the to location data in the format expected by sync_location!.
Methods inherited from Base
Constructor Details
#initialize(data) ⇒ Direction
rubocop:disable Lint/MissingSuper
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 7 def initialize(data) # rubocop:disable Lint/MissingSuper @direction_id = data['direction_id'] @from_location_id = data['from_location_id'] @to_location_id = data['to_location_id'] @travel_time = data['travel_time'] @direction_code = data['dire_code'] from_loc = data['from_location'] || {} @from_location_name = from_loc['loca_name'] @from_location_name_kh = from_loc['loca_name_kh'] to_loc = data['to_location'] || {} @to_location_name = to_loc['loca_name'] @to_location_name_kh = to_loc['loca_name_kh'] end |
Instance Attribute Details
#direction_code ⇒ Object
Returns the value of attribute direction_code.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def direction_code @direction_code end |
#direction_id ⇒ Object
Returns the value of attribute direction_id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def direction_id @direction_id end |
#from_location_id ⇒ Object
Returns the value of attribute from_location_id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def from_location_id @from_location_id end |
#from_location_name ⇒ Object
Returns the value of attribute from_location_name.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def from_location_name @from_location_name end |
#from_location_name_kh ⇒ Object
Returns the value of attribute from_location_name_kh.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def from_location_name_kh @from_location_name_kh end |
#to_location_id ⇒ Object
Returns the value of attribute to_location_id.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def to_location_id @to_location_id end |
#to_location_name ⇒ Object
Returns the value of attribute to_location_name.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def to_location_name @to_location_name end |
#to_location_name_kh ⇒ Object
Returns the value of attribute to_location_name_kh.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def to_location_name_kh @to_location_name_kh end |
#travel_time ⇒ Object
Returns the value of attribute travel_time.
4 5 6 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 4 def travel_time @travel_time end |
Instance Method Details
#display_name ⇒ Object
Returns the display name for this direction
45 46 47 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 45 def display_name "#{from_location_name} → #{to_location_name} (#{direction_code})" end |
#display_name_kh ⇒ Object
Returns the Khmer display name
50 51 52 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 50 def display_name_kh "#{from_location_name_kh} → #{to_location_name_kh} (#{direction_code})" end |
#from_location_data ⇒ Object
Returns the from location data in the format expected by sync_location!
29 30 31 32 33 34 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 29 def from_location_data { 'loca_name' => from_location_name, 'loca_name_kh' => from_location_name_kh } end |
#id ⇒ Object
Returns the direction ID
24 25 26 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 24 def id direction_id end |
#to_h ⇒ Object
Returns a hash representation
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 55 def to_h { id: id, from_location_id: from_location_id, to_location_id: to_location_id, travel_time: travel_time, direction_code: direction_code, from_location_name: from_location_name, from_location_name_kh: from_location_name_kh, to_location_name: to_location_name, to_location_name_kh: to_location_name_kh, display_name: display_name, display_name_kh: display_name_kh } end |
#to_location_data ⇒ Object
Returns the to location data in the format expected by sync_location!
37 38 39 40 41 42 |
# File 'app/services/spree_cm_commissioner/integrations/larryta/resources/direction.rb', line 37 def to_location_data { 'loca_name' => to_location_name, 'loca_name_kh' => to_location_name_kh } end |