Class: GoogleMapsPlatform::PlaceOpeningHoursPeriodDetail

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

Overview

PlaceOpeningHoursPeriodDetail Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(day:, time:, date: SKIP, truncated: SKIP, additional_properties: nil) ⇒ PlaceOpeningHoursPeriodDetail

Returns a new instance of PlaceOpeningHoursPeriodDetail.



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 57

def initialize(day:, time:, date: SKIP, truncated: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @date = date unless date == SKIP
  @day = day
  @time = time
  @truncated = truncated unless truncated == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#dateString

A date expressed in RFC3339 format in the local timezone for the place, for example 2010-12-31.

Returns:

  • (String)


15
16
17
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 15

def date
  @date
end

#dayFloat

A number from 0–6, corresponding to the days of the week, starting on Sunday. For example, 2 means Tuesday.

Returns:

  • (Float)


20
21
22
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 20

def day
  @day
end

#timeString

May contain a time of day in 24-hour hhmm format. Values are in the range 0000–2359. The time will be reported in the place’s time zone.

Returns:

  • (String)


25
26
27
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 25

def time
  @time
end

#truncatedTrueClass | FalseClass

True if a given period was truncated due to a seven-day cutoff, where the period starts before midnight on the date of the request and/or ends at or after midnight on the last day. This property indicates that the period for open or close can extend past this seven-day cutoff.

Returns:

  • (TrueClass | FalseClass)


32
33
34
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 32

def truncated
  @truncated
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 70

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  day = hash.key?('day') ? hash['day'] : nil
  time = hash.key?('time') ? hash['time'] : nil
  date = hash.key?('date') ? hash['date'] : SKIP
  truncated = hash.key?('truncated') ? hash['truncated'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  PlaceOpeningHoursPeriodDetail.new(day: day,
                                    time: time,
                                    date: date,
                                    truncated: truncated,
                                    additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



35
36
37
38
39
40
41
42
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 35

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['date'] = 'date'
  @_hash['day'] = 'day'
  @_hash['time'] = 'time'
  @_hash['truncated'] = 'truncated'
  @_hash
end

.nullablesObject

An array for nullable fields



53
54
55
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 53

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
48
49
50
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 45

def self.optionals
  %w[
    date
    truncated
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



102
103
104
105
106
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 102

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} date: #{@date.inspect}, day: #{@day.inspect}, time: #{@time.inspect},"\
  " truncated: #{@truncated.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



95
96
97
98
99
# File 'lib/google_maps_platform/models/place_opening_hours_period_detail.rb', line 95

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} date: #{@date}, day: #{@day}, time: #{@time}, truncated: #{@truncated},"\
  " additional_properties: #{@additional_properties}>"
end