Class: HQMF2::Range

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/hqmf-parser/2.0/types.rb

Overview

Represents a HQMF physical quantity which can have low and high bounds

Direct Known Subclasses

EffectiveTime

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#attr_val, attr_val, #to_xml

Methods included from HQMF::Conversion::Utilities

#build_hash, #check_equality, #json_array, #openstruct_to_json

Constructor Details

#initialize(entry, type = nil) ⇒ Range

Returns a new instance of Range.



66
67
68
69
70
71
72
73
74
# File 'lib/hqmf-parser/2.0/types.rb', line 66

def initialize(entry, type=nil)
  @type = type
  @entry = entry
  if @entry
    @low = optional_value('./cda:low', default_bounds_type)
    @high = optional_value('./cda:high', default_bounds_type)
    @width = optional_value('./cda:width', 'PQ')
  end
end

Instance Attribute Details

#highObject

Returns the value of attribute high.



64
65
66
# File 'lib/hqmf-parser/2.0/types.rb', line 64

def high
  @high
end

#lowObject

Returns the value of attribute low.



64
65
66
# File 'lib/hqmf-parser/2.0/types.rb', line 64

def low
  @low
end

#widthObject

Returns the value of attribute width.



64
65
66
# File 'lib/hqmf-parser/2.0/types.rb', line 64

def width
  @width
end

Instance Method Details

#to_modelObject



80
81
82
83
84
85
# File 'lib/hqmf-parser/2.0/types.rb', line 80

def to_model
  lm = low ? low.to_model : nil
  hm = high ? high.to_model : nil
  wm = width ? width.to_model : nil
  HQMF::Range.new(type, lm, hm, wm)
end

#typeObject



76
77
78
# File 'lib/hqmf-parser/2.0/types.rb', line 76

def type
  @type || attr_val('./@xsi:type')
end