Class: TestPack1::DataSignalItem

Inherits:
BaseModel show all
Defined in:
lib/test_pack_1/models/data_signal_item.rb

Overview

A data signal, including type.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(data_signal_id = nil, title = nil, type = nil, unit = nil) ⇒ DataSignalItem

Returns a new instance of DataSignalItem.



35
36
37
38
39
40
41
42
43
# File 'lib/test_pack_1/models/data_signal_item.rb', line 35

def initialize(data_signal_id = nil,
               title = nil,
               type = nil,
               unit = nil)
  @data_signal_id = data_signal_id
  @title = title
  @type = type
  @unit = unit
end

Instance Attribute Details

#data_signal_idInteger

The unique id of a data signal.

Returns:

  • (Integer)


11
12
13
# File 'lib/test_pack_1/models/data_signal_item.rb', line 11

def data_signal_id
  @data_signal_id
end

#titleString

The unique id of a data signal.

Returns:



15
16
17
# File 'lib/test_pack_1/models/data_signal_item.rb', line 15

def title
  @title
end

#typeString

The unique id of a data signal.

Returns:



19
20
21
# File 'lib/test_pack_1/models/data_signal_item.rb', line 19

def type
  @type
end

#unitString

The unique id of a data signal.

Returns:



23
24
25
# File 'lib/test_pack_1/models/data_signal_item.rb', line 23

def unit
  @unit
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/test_pack_1/models/data_signal_item.rb', line 46

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  data_signal_id = hash['dataSignalId']
  title = hash['title']
  type = hash['type']
  unit = hash['unit']

  # Create object from extracted values.
  DataSignalItem.new(data_signal_id,
                     title,
                     type,
                     unit)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
33
# File 'lib/test_pack_1/models/data_signal_item.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['data_signal_id'] = 'dataSignalId'
  @_hash['title'] = 'title'
  @_hash['type'] = 'type'
  @_hash['unit'] = 'unit'
  @_hash
end