Class: WalmartApIs::Window
- Defined in:
- lib/walmart_ap_is/models/window.rb
Overview
Contains a start and end DateTime representing a time range.
Instance Attribute Summary collapse
-
#editable_until ⇒ DateTime
The timestamp at which this window can no longer be edited.
-
#mend ⇒ DateTime
The end timestamp of the window.
-
#start ⇒ DateTime
The start timestamp of the window.
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(mend:, start:, editable_until: SKIP, additional_properties: nil) ⇒ Window
constructor
A new instance of Window.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_editable_until ⇒ Object
- #to_custom_mend ⇒ Object
- #to_custom_start ⇒ 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(mend:, start:, editable_until: SKIP, additional_properties: nil) ⇒ Window
Returns a new instance of Window.
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/walmart_ap_is/models/window.rb', line 46 def initialize(mend:, start:, editable_until: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @editable_until = editable_until unless editable_until == SKIP @mend = mend @start = start @additional_properties = additional_properties end |
Instance Attribute Details
#editable_until ⇒ DateTime
The timestamp at which this window can no longer be edited.
15 16 17 |
# File 'lib/walmart_ap_is/models/window.rb', line 15 def editable_until @editable_until end |
#mend ⇒ DateTime
The end timestamp of the window.
19 20 21 |
# File 'lib/walmart_ap_is/models/window.rb', line 19 def mend @mend end |
#start ⇒ DateTime
The start timestamp of the window.
23 24 25 |
# File 'lib/walmart_ap_is/models/window.rb', line 23 def start @start 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 79 80 81 82 83 84 85 86 |
# File 'lib/walmart_ap_is/models/window.rb', line 58 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. mend = if hash.key?('end') (DateTimeHelper.from_rfc3339(hash['end']) if hash['end']) end start = if hash.key?('start') (DateTimeHelper.from_rfc3339(hash['start']) if hash['start']) end editable_until = if hash.key?('editableUntil') (DateTimeHelper.from_rfc3339(hash['editableUntil']) if hash['editableUntil']) else SKIP end # 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. Window.new(mend: mend, start: start, editable_until: editable_until, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
26 27 28 29 30 31 32 |
# File 'lib/walmart_ap_is/models/window.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['editable_until'] = 'editableUntil' @_hash['mend'] = 'end' @_hash['start'] = 'start' @_hash end |
.nullables ⇒ Object
An array for nullable fields
42 43 44 |
# File 'lib/walmart_ap_is/models/window.rb', line 42 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 38 39 |
# File 'lib/walmart_ap_is/models/window.rb', line 35 def self.optionals %w[ editable_until ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
108 109 110 111 112 |
# File 'lib/walmart_ap_is/models/window.rb', line 108 def inspect class_name = self.class.name.split('::').last "<#{class_name} editable_until: #{@editable_until.inspect}, mend: #{@mend.inspect}, start:"\ " #{@start.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_editable_until ⇒ Object
88 89 90 |
# File 'lib/walmart_ap_is/models/window.rb', line 88 def to_custom_editable_until DateTimeHelper.to_rfc3339(editable_until) end |
#to_custom_mend ⇒ Object
92 93 94 |
# File 'lib/walmart_ap_is/models/window.rb', line 92 def to_custom_mend DateTimeHelper.to_rfc3339(mend) end |
#to_custom_start ⇒ Object
96 97 98 |
# File 'lib/walmart_ap_is/models/window.rb', line 96 def to_custom_start DateTimeHelper.to_rfc3339(start) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
101 102 103 104 105 |
# File 'lib/walmart_ap_is/models/window.rb', line 101 def to_s class_name = self.class.name.split('::').last "<#{class_name} editable_until: #{@editable_until}, mend: #{@mend}, start: #{@start},"\ " additional_properties: #{@additional_properties}>" end |