Class: GoogleMapsPlatform::TrafficModel

Inherits:
Object
  • Object
show all
Defined in:
lib/google_maps_platform/models/traffic_model.rb

Overview

traffic_model.

Constant Summary collapse

TRAFFIC_MODEL =
[
  # TODO: Write general description for BEST_GUESS
  BEST_GUESS = 'best_guess'.freeze,

  # TODO: Write general description for PESSIMISTIC
  PESSIMISTIC = 'pessimistic'.freeze,

  # TODO: Write general description for OPTIMISTIC
  OPTIMISTIC = 'optimistic'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = BEST_GUESS) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/google_maps_platform/models/traffic_model.rb', line 26

def self.from_value(value, default_value = BEST_GUESS)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'best_guess' then BEST_GUESS
  when 'pessimistic' then PESSIMISTIC
  when 'optimistic' then OPTIMISTIC
  else
    default_value
  end
end

.validate(value) ⇒ Object



20
21
22
23
24
# File 'lib/google_maps_platform/models/traffic_model.rb', line 20

def self.validate(value)
  return false if value.nil?

  TRAFFIC_MODEL.include?(value)
end