Class: HQMF::Collection
- Inherits:
-
Object
- Object
- HQMF::Collection
- Includes:
- HQMF::Conversion::Utilities
- Defined in:
- lib/hqmf-model/types.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
-
#values ⇒ Object
Returns the value of attribute values.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, values) ⇒ Collection
constructor
A new instance of Collection.
- #to_json ⇒ Object
Methods included from HQMF::Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(type, values) ⇒ Collection
Returns a new instance of Collection.
432 433 434 435 |
# File 'lib/hqmf-model/types.rb', line 432 def initialize(type, values) @type = type || 'COL' @values = values || [] end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
430 431 432 |
# File 'lib/hqmf-model/types.rb', line 430 def type @type end |
#values ⇒ Object
Returns the value of attribute values.
430 431 432 |
# File 'lib/hqmf-model/types.rb', line 430 def values @values end |
Class Method Details
.from_json(json) ⇒ Object
437 438 439 440 441 442 443 |
# File 'lib/hqmf-model/types.rb', line 437 def self.from_json(json) json = json.with_indifferent_access values = [] type = json['type'] json['values'].each { |value| values.push(HQMF::DataCriteria.convert_value(value))} HQMF::Collection.new(type, values) end |
Instance Method Details
#==(other) ⇒ Object
452 453 454 |
# File 'lib/hqmf-model/types.rb', line 452 def ==(other) check_equality(self,other) end |
#to_json ⇒ Object
445 446 447 448 449 450 |
# File 'lib/hqmf-model/types.rb', line 445 def to_json json = build_hash(self, [:type]) json[:values] = [] @values.each {|value| json[:values] << value.to_json } json end |