Class: CtdDocumentation::Information

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/ctd_documentation/models/information.rb

Overview

Information Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(site_id = SKIP, resource_id = SKIP, id = SKIP, asset_id = SKIP, code_sections = SKIP, source = SKIP, originator_name = SKIP, originator_number = SKIP, information_type_name = SKIP, information_type_number = SKIP, approved = SKIP, valid = SKIP, timestamp = SKIP) ⇒ Information

Returns a new instance of Information.



107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/ctd_documentation/models/information.rb', line 107

def initialize(site_id = SKIP,
               resource_id = SKIP,
               id = SKIP,
               asset_id = SKIP,
               code_sections = SKIP,
               source = SKIP,
               originator_name = SKIP,
               originator_number = SKIP,
               information_type_name = SKIP,
               information_type_number = SKIP,
               approved = SKIP,
               valid = SKIP,
               timestamp = SKIP)
  @site_id = site_id unless site_id == SKIP
  @resource_id = resource_id unless resource_id == SKIP
  @id = id unless id == SKIP
  @asset_id = asset_id unless asset_id == SKIP
  @code_sections = code_sections unless code_sections == SKIP
  @source = source unless source == SKIP
  @originator_name = originator_name unless originator_name == SKIP
  @originator_number = originator_number unless originator_number == SKIP
  @information_type_name = information_type_name unless information_type_name == SKIP
  @information_type_number = information_type_number unless information_type_number == SKIP
  @approved = approved unless approved == SKIP
  @valid = valid unless valid == SKIP
  @timestamp = timestamp unless timestamp == SKIP
end

Instance Attribute Details

#approvedTrueClass|FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass|FalseClass)


54
55
56
# File 'lib/ctd_documentation/models/information.rb', line 54

def approved
  @approved
end

#asset_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


26
27
28
# File 'lib/ctd_documentation/models/information.rb', line 26

def asset_id
  @asset_id
end

#code_sectionsList of CodeSections

TODO: Write general description for this method

Returns:



30
31
32
# File 'lib/ctd_documentation/models/information.rb', line 30

def code_sections
  @code_sections
end

#idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


22
23
24
# File 'lib/ctd_documentation/models/information.rb', line 22

def id
  @id
end

#information_type_nameString

TODO: Write general description for this method

Returns:

  • (String)


46
47
48
# File 'lib/ctd_documentation/models/information.rb', line 46

def information_type_name
  @information_type_name
end

#information_type_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


50
51
52
# File 'lib/ctd_documentation/models/information.rb', line 50

def information_type_number
  @information_type_number
end

#originator_nameString

TODO: Write general description for this method

Returns:

  • (String)


38
39
40
# File 'lib/ctd_documentation/models/information.rb', line 38

def originator_name
  @originator_name
end

#originator_numberInteger

TODO: Write general description for this method

Returns:

  • (Integer)


42
43
44
# File 'lib/ctd_documentation/models/information.rb', line 42

def originator_number
  @originator_number
end

#resource_idString

TODO: Write general description for this method

Returns:

  • (String)


18
19
20
# File 'lib/ctd_documentation/models/information.rb', line 18

def resource_id
  @resource_id
end

#site_idInteger

TODO: Write general description for this method

Returns:

  • (Integer)


14
15
16
# File 'lib/ctd_documentation/models/information.rb', line 14

def site_id
  @site_id
end

#sourceString

TODO: Write general description for this method

Returns:

  • (String)


34
35
36
# File 'lib/ctd_documentation/models/information.rb', line 34

def source
  @source
end

#timestampString

TODO: Write general description for this method

Returns:

  • (String)


62
63
64
# File 'lib/ctd_documentation/models/information.rb', line 62

def timestamp
  @timestamp
end

#validTrueClass|FalseClass

TODO: Write general description for this method

Returns:

  • (TrueClass|FalseClass)


58
59
60
# File 'lib/ctd_documentation/models/information.rb', line 58

def valid
  @valid
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/ctd_documentation/models/information.rb', line 136

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  resource_id = hash.key?('resource_id') ? hash['resource_id'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  asset_id = hash.key?('asset_id') ? hash['asset_id'] : SKIP
  # Parameter is an array, so we need to iterate through it

  code_sections = nil
  unless hash['code_sections'].nil?
    code_sections = []
    hash['code_sections'].each do |structure|
      code_sections << (CodeSections.from_hash(structure) if structure)
    end
  end

  code_sections = SKIP unless hash.key?('code_sections')
  source = hash.key?('source') ? hash['source'] : SKIP
  originator_name =
    hash.key?('originator_name') ? hash['originator_name'] : SKIP
  originator_number =
    hash.key?('originator_number') ? hash['originator_number'] : SKIP
  information_type_name =
    hash.key?('information_type_name') ? hash['information_type_name'] : SKIP
  information_type_number =
    hash.key?('information_type_number') ? hash['information_type_number'] : SKIP
  approved = hash.key?('approved') ? hash['approved'] : SKIP
  valid = hash.key?('valid') ? hash['valid'] : SKIP
  timestamp = hash.key?('timestamp') ? hash['timestamp'] : SKIP

  # Create object from extracted values.

  Information.new(site_id,
                  resource_id,
                  id,
                  asset_id,
                  code_sections,
                  source,
                  originator_name,
                  originator_number,
                  information_type_name,
                  information_type_number,
                  approved,
                  valid,
                  timestamp)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/ctd_documentation/models/information.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['site_id'] = 'site_id'
  @_hash['resource_id'] = 'resource_id'
  @_hash['id'] = 'id'
  @_hash['asset_id'] = 'asset_id'
  @_hash['code_sections'] = 'code_sections'
  @_hash['source'] = 'source'
  @_hash['originator_name'] = 'originator_name'
  @_hash['originator_number'] = 'originator_number'
  @_hash['information_type_name'] = 'information_type_name'
  @_hash['information_type_number'] = 'information_type_number'
  @_hash['approved'] = 'approved'
  @_hash['valid'] = 'valid'
  @_hash['timestamp'] = 'timestamp'
  @_hash
end

.nullablesObject

An array for nullable fields



103
104
105
# File 'lib/ctd_documentation/models/information.rb', line 103

def self.nullables
  []
end

.optionalsObject

An array for optional fields



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/ctd_documentation/models/information.rb', line 84

def self.optionals
  %w[
    site_id
    resource_id
    id
    asset_id
    code_sections
    source
    originator_name
    originator_number
    information_type_name
    information_type_number
    approved
    valid
    timestamp
  ]
end