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.



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

#highObject

Returns the value of attribute high.



60
61
62
# File 'lib/hqmf-parser/2.0/types.rb', line 60

def high
  @high
end

#lowObject

Returns the value of attribute low.



60
61
62
# File 'lib/hqmf-parser/2.0/types.rb', line 60

def low
  @low
end

#widthObject

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_modelObject



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

#typeObject



72
73
74
# File 'lib/hqmf-parser/2.0/types.rb', line 72

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