Class: GoogleMapsPlatform::TimeZoneTextValueObject

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

Overview

An object containing Unix time, a time zone, and its formatted text representation.

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(text:, value:, time_zone:, additional_properties: nil) ⇒ TimeZoneTextValueObject

Returns a new instance of TimeZoneTextValueObject.



47
48
49
50
51
52
53
54
55
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 47

def initialize(text:, value:, time_zone:, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @text = text
  @value = value
  @time_zone = time_zone
  @additional_properties = additional_properties
end

Instance Attribute Details

#textString

The time specified as a string in the time zone.

Returns:

  • (String)


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

def text
  @text
end

#time_zoneString

Contains the time zone. The value is the name of the time zone as defined in the [IANA Time Zone Database](www.iana.org/time-zones), e.g. “America/New_York”.

Returns:

  • (String)


26
27
28
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 26

def time_zone
  @time_zone
end

#valueFloat

The time specified as Unix time, or seconds since midnight, January 1, 1970 UTC.

Returns:

  • (Float)


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

def value
  @value
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  text = hash.key?('text') ? hash['text'] : nil
  value = hash.key?('value') ? hash['value'] : nil
  time_zone = hash.key?('time_zone') ? hash['time_zone'] : nil

  # 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.
  TimeZoneTextValueObject.new(text: text,
                              value: value,
                              time_zone: time_zone,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['text'] = 'text'
  @_hash['value'] = 'value'
  @_hash['time_zone'] = 'time_zone'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 38

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



88
89
90
91
92
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 88

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} text: #{@text.inspect}, value: #{@value.inspect}, time_zone:"\
  " #{@time_zone.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



81
82
83
84
85
# File 'lib/google_maps_platform/models/time_zone_text_value_object.rb', line 81

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} text: #{@text}, value: #{@value}, time_zone: #{@time_zone},"\
  " additional_properties: #{@additional_properties}>"
end