Class: SpreeCmCommissioner::IntercityTaxi::Distance
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::IntercityTaxi::Distance
- Defined in:
- lib/spree_cm_commissioner/intercity_taxi/distance.rb
Instance Attribute Summary collapse
-
#base_km ⇒ Object
Returns the value of attribute base_km.
-
#detour_dropoff_km ⇒ Object
Returns the value of attribute detour_dropoff_km.
-
#detour_pickup_km ⇒ Object
Returns the value of attribute detour_pickup_km.
-
#distance_km ⇒ Object
Returns the value of attribute distance_km.
-
#estimated_time_minutes ⇒ Object
Returns the value of attribute estimated_time_minutes.
-
#extra_dropoff_km ⇒ Object
Returns the value of attribute extra_dropoff_km.
-
#extra_pickup_km ⇒ Object
Returns the value of attribute extra_pickup_km.
-
#ordered_points ⇒ Object
Returns the value of attribute ordered_points.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Distance
constructor
A new instance of Distance.
- #to_h ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Distance
Returns a new instance of Distance.
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 7 def initialize( = {}) = .stringify_keys if .is_a?(Hash) @distance_km = ['distance_km']&.to_f @ordered_points = ['ordered_points'] @estimated_time_minutes = ['estimated_time_minutes']&.to_i @base_km = ['base_km']&.to_f @detour_pickup_km = ['detour_pickup_km']&.to_f @detour_dropoff_km = ['detour_dropoff_km']&.to_f @extra_pickup_km = ['extra_pickup_km']&.to_f @extra_dropoff_km = ['extra_dropoff_km']&.to_f end |
Instance Attribute Details
#base_km ⇒ Object
Returns the value of attribute base_km.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def base_km @base_km end |
#detour_dropoff_km ⇒ Object
Returns the value of attribute detour_dropoff_km.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def detour_dropoff_km @detour_dropoff_km end |
#detour_pickup_km ⇒ Object
Returns the value of attribute detour_pickup_km.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def detour_pickup_km @detour_pickup_km end |
#distance_km ⇒ Object
Returns the value of attribute distance_km.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def distance_km @distance_km end |
#estimated_time_minutes ⇒ Object
Returns the value of attribute estimated_time_minutes.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def estimated_time_minutes @estimated_time_minutes end |
#extra_dropoff_km ⇒ Object
Returns the value of attribute extra_dropoff_km.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def extra_dropoff_km @extra_dropoff_km end |
#extra_pickup_km ⇒ Object
Returns the value of attribute extra_pickup_km.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def extra_pickup_km @extra_pickup_km end |
#ordered_points ⇒ Object
Returns the value of attribute ordered_points.
4 5 6 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 4 def ordered_points @ordered_points end |
Class Method Details
.from_hash(hash) ⇒ Object
20 21 22 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 20 def self.from_hash(hash) new(hash || {}) end |
Instance Method Details
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/spree_cm_commissioner/intercity_taxi/distance.rb', line 24 def to_h { 'distance_km' => @distance_km, 'ordered_points' => @ordered_points, 'estimated_time_minutes' => @estimated_time_minutes, 'base_km' => @base_km, 'detour_pickup_km' => @detour_pickup_km, 'detour_dropoff_km' => @detour_dropoff_km, 'extra_pickup_km' => @extra_pickup_km, 'extra_dropoff_km' => @extra_dropoff_km }.compact end |