Class: Verizon::Item
- Defined in:
- lib/verizon/models/item.rb
Overview
Item Model.
Instance Attribute Summary collapse
-
#itis ⇒ Integer
The ITIS Code that describes the alert/danger/hazard.
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(itis:) ⇒ Item
constructor
A new instance of Item.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(itis:) ⇒ Item
Returns a new instance of Item.
38 39 40 |
# File 'lib/verizon/models/item.rb', line 38 def initialize(itis:) @itis = itis end |
Instance Attribute Details
#itis ⇒ Integer
The ITIS Code that describes the alert/danger/hazard. All ITS standards use the same types here to explain the type of the alert/danger/hazard involved. The complete set of ITIS codes can be found in Volume Two of the SAE J2540 standard. This is a set of over 1000 items which are used to encode common events and list items in ITS.
19 20 21 |
# File 'lib/verizon/models/item.rb', line 19 def itis @itis end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
43 44 45 46 47 48 49 50 51 |
# File 'lib/verizon/models/item.rb', line 43 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. itis = hash.key?('itis') ? hash['itis'] : nil # Create object from extracted values. Item.new(itis: itis) end |
.names ⇒ Object
A mapping from model property names to API property names.
22 23 24 25 26 |
# File 'lib/verizon/models/item.rb', line 22 def self.names @_hash = {} if @_hash.nil? @_hash['itis'] = 'itis' @_hash end |
.nullables ⇒ Object
An array for nullable fields
34 35 36 |
# File 'lib/verizon/models/item.rb', line 34 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
29 30 31 |
# File 'lib/verizon/models/item.rb', line 29 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/verizon/models/item.rb', line 55 def self.validate(value) if value.instance_of? self return APIHelper.valid_type?(value.itis, ->(val) { val.instance_of? Integer }) end return false unless value.instance_of? Hash APIHelper.valid_type?(value['itis'], ->(val) { val.instance_of? Integer }) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
74 75 76 77 |
# File 'lib/verizon/models/item.rb', line 74 def inspect class_name = self.class.name.split('::').last "<#{class_name} itis: #{@itis.inspect}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
68 69 70 71 |
# File 'lib/verizon/models/item.rb', line 68 def to_s class_name = self.class.name.split('::').last "<#{class_name} itis: #{@itis}>" end |