Class: HQMF::Attribute
- Inherits:
-
Object
- Object
- HQMF::Attribute
- Includes:
- Conversion::Utilities
- Defined in:
- lib/hqmf-model/attribute.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, code, value, unit, name) ⇒ Attribute
constructor
A new instance of Attribute.
- #to_json ⇒ Object
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.
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
#code ⇒ Object (readonly)
Returns the value of attribute code.
5 6 7 |
# File 'lib/hqmf-model/attribute.rb', line 5 def code @code end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/hqmf-model/attribute.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/hqmf-model/attribute.rb', line 5 def name @name end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
5 6 7 |
# File 'lib/hqmf-model/attribute.rb', line 5 def unit @unit end |
#value ⇒ Object (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_json ⇒ Object
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 |