Class: Verizon::CauseCodeChoice1

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/cause_code_choice1.rb

Overview

CauseCodeChoice1 Model.

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(accident2 = nil) ⇒ CauseCodeChoice1

Returns a new instance of CauseCodeChoice1.



54
55
56
# File 'lib/verizon/models/cause_code_choice1.rb', line 54

def initialize(accident2 = nil)
  @accident2 = accident2
end

Instance Attribute Details

#accident2Integer

The value shall be set to:

  • 0 ‘unavailable` - in case the information on the

sub cause of the accident is unavailable,

  • 1 ‘multiVehicleAccident` - in case more than two vehicles

are involved in accident,

  • 2 ‘heavyAccident` - in case the airbag of the

vehicle involved in the accident is triggered,

  • the accident requires important

rescue and/or recovery work,

  • 3 ‘accidentInvolvingLorry` - in case the accident involves a

lorry,

  • 4 ‘accidentInvolvingBus` - in case the accident involves a

bus,

  • 5 ‘accidentInvolvingHazardousMaterials`- in case the accident involves

hazardous material,

  • 6 ‘accidentOnOppositeLane` - in case the accident happens on

opposite lanes,

  • 7 ‘unsecuredAccident` - in case the accident is not

secured,

  • 8 ‘assistanceRequested` - in case rescue and assistance

are requested,

  • 9-255 - reserved for future usage.

Returns:

  • (Integer)


35
36
37
# File 'lib/verizon/models/cause_code_choice1.rb', line 35

def accident2
  @accident2
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



59
60
61
62
63
64
65
66
67
# File 'lib/verizon/models/cause_code_choice1.rb', line 59

def self.from_hash(hash)
  return nil unless hash

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

  # Create object from extracted values.
  CauseCodeChoice1.new(accident2)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
# File 'lib/verizon/models/cause_code_choice1.rb', line 38

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

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/verizon/models/cause_code_choice1.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



45
46
47
# File 'lib/verizon/models/cause_code_choice1.rb', line 45

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/verizon/models/cause_code_choice1.rb', line 71

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.accident2,
                                 ->(val) { val.instance_of? Integer })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['accident2'],
                        ->(val) { val.instance_of? Integer })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



90
91
92
93
# File 'lib/verizon/models/cause_code_choice1.rb', line 90

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} accident2: #{@accident2.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



84
85
86
87
# File 'lib/verizon/models/cause_code_choice1.rb', line 84

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} accident2: #{@accident2}>"
end