Class: HQMF::Attribute

Inherits:
Object
  • Object
show all
Includes:
Conversion::Utilities
Defined in:
lib/hqmf-model/attribute.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(id, code, value, unit, name) ⇒ Attribute

Returns a new instance of Attribute.

Parameters:

  • id (String)
  • code (String)
  • value (String)
  • unit (String)
  • name (String)


11
12
13
14
15
16
17
# File 'lib/hqmf-model/attribute.rb', line 11

def initialize(id,code,value,unit,name)
  @id = id
  @code = code
  @value = value
  @unit = unit
  @name = name
end

Instance Attribute Details

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/hqmf-model/attribute.rb', line 5

def code
  @code
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/hqmf-model/attribute.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/hqmf-model/attribute.rb', line 5

def name
  @name
end

#unitObject (readonly)

Returns the value of attribute unit.



5
6
7
# File 'lib/hqmf-model/attribute.rb', line 5

def unit
  @unit
end

#valueObject (readonly)

Returns the value of attribute value.



5
6
7
# File 'lib/hqmf-model/attribute.rb', line 5

def value
  @value
end

Class Method Details

.from_json(json) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/hqmf-model/attribute.rb', line 19

def self.from_json(json)
  id = json["id"] if json["id"]
  code = json["code"] if json["code"]
  value = json["value"] if json["value"]
  unit = json["unit"] if json["unit"]
  name = json["name"] if json["name"]

  HQMF::Attribute.new(id,code,value,unit,name)
end

Instance Method Details

#to_jsonObject



29
30
31
32
# File 'lib/hqmf-model/attribute.rb', line 29

def to_json
  json = build_hash(self, [:id,:code,:value,:unit,:name])
  json
end