Class: CalendarApi::EventDateTime
- Defined in:
- lib/calendar_api/models/event_date_time.rb
Overview
A timestamp marking the start or end of an event. For all-day events, use date; for timed events, use dateTime.
Instance Attribute Summary collapse
-
#date ⇒ Date
The date, in the format “yyyy-mm-dd”, if this is an all-day event.
-
#date_time ⇒ DateTime
The time, as a combined date-time value (RFC3339).
-
#time_zone ⇒ String
The time zone in which the time is specified.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(date: SKIP, date_time: SKIP, time_zone: SKIP, additional_properties: nil) ⇒ EventDateTime
constructor
A new instance of EventDateTime.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_date_time ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(date: SKIP, date_time: SKIP, time_zone: SKIP, additional_properties: nil) ⇒ EventDateTime
Returns a new instance of EventDateTime.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/calendar_api/models/event_date_time.rb', line 51 def initialize(date: SKIP, date_time: SKIP, time_zone: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @date = date unless date == SKIP @date_time = date_time unless date_time == SKIP @time_zone = time_zone unless time_zone == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#date ⇒ Date
The date, in the format “yyyy-mm-dd”, if this is an all-day event.
16 17 18 |
# File 'lib/calendar_api/models/event_date_time.rb', line 16 def date @date end |
#date_time ⇒ DateTime
The time, as a combined date-time value (RFC3339). A time zone offset is required unless a time zone is explicitly specified in timeZone.
21 22 23 |
# File 'lib/calendar_api/models/event_date_time.rb', line 21 def date_time @date_time end |
#time_zone ⇒ String
The time zone in which the time is specified. Formatted as an IANA Time Zone Database name, e.g. “America/New_York”.
26 27 28 |
# File 'lib/calendar_api/models/event_date_time.rb', line 26 def time_zone @time_zone end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/calendar_api/models/event_date_time.rb', line 63 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. date = hash.key?('date') ? hash['date'] : SKIP date_time = if hash.key?('dateTime') (DateTimeHelper.from_rfc3339(hash['dateTime']) if hash['dateTime']) else SKIP end time_zone = hash.key?('timeZone') ? hash['timeZone'] : 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. EventDateTime.new(date: date, date_time: date_time, time_zone: time_zone, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
29 30 31 32 33 34 35 |
# File 'lib/calendar_api/models/event_date_time.rb', line 29 def self.names @_hash = {} if @_hash.nil? @_hash['date'] = 'date' @_hash['date_time'] = 'dateTime' @_hash['time_zone'] = 'timeZone' @_hash end |
.nullables ⇒ Object
An array for nullable fields
47 48 49 |
# File 'lib/calendar_api/models/event_date_time.rb', line 47 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
38 39 40 41 42 43 44 |
# File 'lib/calendar_api/models/event_date_time.rb', line 38 def self.optionals %w[ date date_time time_zone ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
101 102 103 104 105 |
# File 'lib/calendar_api/models/event_date_time.rb', line 101 def inspect class_name = self.class.name.split('::').last "<#{class_name} date: #{@date.inspect}, date_time: #{@date_time.inspect}, time_zone:"\ " #{@time_zone.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_date_time ⇒ Object
89 90 91 |
# File 'lib/calendar_api/models/event_date_time.rb', line 89 def to_custom_date_time DateTimeHelper.to_rfc3339(date_time) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
94 95 96 97 98 |
# File 'lib/calendar_api/models/event_date_time.rb', line 94 def to_s class_name = self.class.name.split('::').last "<#{class_name} date: #{@date}, date_time: #{@date_time}, time_zone: #{@time_zone},"\ " additional_properties: #{@additional_properties}>" end |