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.
-
#code_obj ⇒ Object
readonly
Returns the value of attribute code_obj.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#id_obj ⇒ Object
readonly
Returns the value of attribute id_obj.
-
#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.
-
#value_obj ⇒ Object
readonly
Returns the value of attribute value_obj.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(id, code, value, unit, name, id_obj = nil, code_obj = nil, value_obj = nil) ⇒ 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, id_obj = nil, code_obj = nil, value_obj = nil) ⇒ Attribute
Returns a new instance of Attribute.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/hqmf-model/attribute.rb', line 13 def initialize(id,code,value,unit,name,id_obj=nil,code_obj=nil,value_obj=nil) @id = id @code = code @value = value @unit = unit @name = name # enhanced model @id_obj = id_obj @code_obj = code_obj @value_obj = value_obj end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def code @code end |
#code_obj ⇒ Object (readonly)
Returns the value of attribute code_obj.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def code_obj @code_obj end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def id @id end |
#id_obj ⇒ Object (readonly)
Returns the value of attribute id_obj.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def id_obj @id_obj end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def name @name end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def unit @unit end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def value @value end |
#value_obj ⇒ Object (readonly)
Returns the value of attribute value_obj.
4 5 6 |
# File 'lib/hqmf-model/attribute.rb', line 4 def value_obj @value_obj end |
Class Method Details
.from_json(json) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/hqmf-model/attribute.rb', line 25 def self.from_json(json) json = json.with_indifferent_access 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"] # enhanced model id_obj = HQMF::Identifier::from_json(json["id_obj"]) if json["id_obj"] code_obj = HQMF::Coded::from_json(json["code_obj"]) if json["code_obj"] value_obj = nil if (json["value_obj"]) json_value = json["value_obj"].with_indifferent_access case json_value["type"] when 'II' value_obj = HQMF::Identifier::from_json(json_value) when 'CD' value_obj = HQMF::Coded::from_json(json_value) when 'ED' value_obj = HQMF::ED::from_json(json_value) else value_obj = json_value["value"].nil? ? HQMF::AnyValue::from_json(json_value) : HQMF::GenericValueContainer::from_json(json_value) end end HQMF::Attribute.new(id,code,value,unit,name,id_obj,code_obj,value_obj) end |
Instance Method Details
#to_json ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/hqmf-model/attribute.rb', line 54 def to_json json = build_hash(self, [:id,:code,:value,:unit,:name]) json[:id_obj] = @id_obj.to_json if @id_obj json[:code_obj] = @code_obj.to_json if @code_obj json[:value_obj] = @value_obj.to_json if @value_obj json end |