Class: ApiReference::Usage
- Defined in:
- lib/api_reference/models/usage.rb
Overview
Usage Model.
Instance Attribute Summary collapse
-
#quantity ⇒ Float
TODO: Write general description for this method.
-
#timeframe_end ⇒ DateTime
TODO: Write general description for this method.
-
#timeframe_start ⇒ DateTime
TODO: Write general description for this method.
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.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(quantity:, timeframe_start:, timeframe_end:, additional_properties: nil) ⇒ Usage
constructor
A new instance of Usage.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_timeframe_end ⇒ Object
- #to_custom_timeframe_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(quantity:, timeframe_start:, timeframe_end:, additional_properties: nil) ⇒ Usage
Returns a new instance of Usage.
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/api_reference/models/usage.rb', line 44 def initialize(quantity:, timeframe_start:, timeframe_end:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @quantity = quantity @timeframe_start = timeframe_start @timeframe_end = timeframe_end @additional_properties = additional_properties end |
Instance Attribute Details
#quantity ⇒ Float
TODO: Write general description for this method
15 16 17 |
# File 'lib/api_reference/models/usage.rb', line 15 def quantity @quantity end |
#timeframe_end ⇒ DateTime
TODO: Write general description for this method
23 24 25 |
# File 'lib/api_reference/models/usage.rb', line 23 def timeframe_end @timeframe_end end |
#timeframe_start ⇒ DateTime
TODO: Write general description for this method
19 20 21 |
# File 'lib/api_reference/models/usage.rb', line 19 def timeframe_start @timeframe_start end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/api_reference/models/usage.rb', line 56 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. quantity = hash.key?('quantity') ? hash['quantity'] : nil timeframe_start = if hash.key?('timeframe_start') (DateTimeHelper.from_rfc3339(hash['timeframe_start']) if hash['timeframe_start']) end timeframe_end = if hash.key?('timeframe_end') (DateTimeHelper.from_rfc3339(hash['timeframe_end']) if hash['timeframe_end']) 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. Usage.new(quantity: quantity, timeframe_start: timeframe_start, timeframe_end: timeframe_end, 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/api_reference/models/usage.rb', line 26 def self.names @_hash = {} if @_hash.nil? @_hash['quantity'] = 'quantity' @_hash['timeframe_start'] = 'timeframe_start' @_hash['timeframe_end'] = 'timeframe_end' @_hash end |
.nullables ⇒ Object
An array for nullable fields
40 41 42 |
# File 'lib/api_reference/models/usage.rb', line 40 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
35 36 37 |
# File 'lib/api_reference/models/usage.rb', line 35 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/api_reference/models/usage.rb', line 92 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.quantity, ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value.timeframe_start, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.timeframe_end, ->(val) { val.instance_of? DateTime }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['quantity'], ->(val) { val.instance_of? Float }) and APIHelper.valid_type?(value['timeframe_start'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['timeframe_end'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
124 125 126 127 128 129 |
# File 'lib/api_reference/models/usage.rb', line 124 def inspect class_name = self.class.name.split('::').last "<#{class_name} quantity: #{@quantity.inspect}, timeframe_start:"\ " #{@timeframe_start.inspect}, timeframe_end: #{@timeframe_end.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_custom_timeframe_end ⇒ Object
86 87 88 |
# File 'lib/api_reference/models/usage.rb', line 86 def to_custom_timeframe_end DateTimeHelper.to_rfc3339(timeframe_end) end |
#to_custom_timeframe_start ⇒ Object
82 83 84 |
# File 'lib/api_reference/models/usage.rb', line 82 def to_custom_timeframe_start DateTimeHelper.to_rfc3339(timeframe_start) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
117 118 119 120 121 |
# File 'lib/api_reference/models/usage.rb', line 117 def to_s class_name = self.class.name.split('::').last "<#{class_name} quantity: #{@quantity}, timeframe_start: #{@timeframe_start},"\ " timeframe_end: #{@timeframe_end}, additional_properties: #{@additional_properties}>" end |