Class: SpreeCmCommissioner::IntercityTaxi::MapPlace

Inherits:
Object
  • Object
show all
Defined in:
lib/spree_cm_commissioner/intercity_taxi/map_place.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ MapPlace

Returns a new instance of MapPlace.



6
7
8
9
10
11
12
13
14
15
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 6

def initialize(options = {})
  options = options.stringify_keys if options.is_a?(Hash)

  @place_name = options['place_name']
  @lat = options['lat']&.to_f
  @lng = options['lng']&.to_f

  # Normalize truthy/falsey values ("true", "1", 1, etc.) to a real boolean.
  @oob_confirmed = ActiveModel::Type::Boolean.new.cast(options['oob_confirmed'])
end

Instance Attribute Details

#latObject

Returns the value of attribute lat.



4
5
6
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 4

def lat
  @lat
end

#lngObject

Returns the value of attribute lng.



4
5
6
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 4

def lng
  @lng
end

#oob_confirmedObject

Returns the value of attribute oob_confirmed.



4
5
6
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 4

def oob_confirmed
  @oob_confirmed
end

#place_nameObject

Returns the value of attribute place_name.



4
5
6
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 4

def place_name
  @place_name
end

Class Method Details

.from_hash(hash) ⇒ Object



17
18
19
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 17

def self.from_hash(hash)
  new(hash || {})
end

Instance Method Details

#to_hObject



21
22
23
24
25
26
27
28
# File 'lib/spree_cm_commissioner/intercity_taxi/map_place.rb', line 21

def to_h
  {
    'place_name' => @place_name,
    'lat' => @lat,
    'lng' => @lng,
    'oob_confirmed' => @oob_confirmed
  }.compact
end