Class: HQMF2::Range
- Inherits:
-
Object
- Object
- HQMF2::Range
- 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
Instance Attribute Summary collapse
-
#high ⇒ Object
Returns the value of attribute high.
-
#low ⇒ Object
Returns the value of attribute low.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(entry, type = nil) ⇒ Range
constructor
A new instance of Range.
- #to_model ⇒ Object
- #type ⇒ Object
Methods included from Utilities
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.
62 63 64 65 66 67 68 69 70 |
# File 'lib/hqmf-parser/2.0/types.rb', line 62 def initialize(entry, type=nil) @type = type @entry = entry if @entry @low = optional_value("#{default_element_name}/cda:low", default_bounds_type) @high = optional_value("#{default_element_name}/cda:high", default_bounds_type) @width = optional_value("#{default_element_name}/cda:width", 'PQ') end end |
Instance Attribute Details
#high ⇒ Object
Returns the value of attribute high.
60 61 62 |
# File 'lib/hqmf-parser/2.0/types.rb', line 60 def high @high end |
#low ⇒ Object
Returns the value of attribute low.
60 61 62 |
# File 'lib/hqmf-parser/2.0/types.rb', line 60 def low @low end |
#width ⇒ Object
Returns the value of attribute width.
60 61 62 |
# File 'lib/hqmf-parser/2.0/types.rb', line 60 def width @width end |
Instance Method Details
#to_model ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/hqmf-parser/2.0/types.rb', line 76 def to_model lm = low ? low.to_model : nil hm = high ? high.to_model : nil wm = width ? width.to_model : nil model_type = type if @entry.at_xpath('./cda:uncertainRange', HQMF2::Document::NAMESPACES) model_type = 'IVL_PQ' end HQMF::Range.new(model_type, lm, hm, wm) end |
#type ⇒ Object
72 73 74 |
# File 'lib/hqmf-parser/2.0/types.rb', line 72 def type @type || attr_val('./@xsi:type') end |