class SimpleXml::Range
Represents a HQMF physical quantity which can have low and high bounds
Attributes
high[RW]
low[RW]
type[RW]
width[RW]
Public Class Methods
new(comparison, quantity, unit, type=nil)
click to toggle source
# File lib/model/types.rb, line 61 def initialize(comparison, quantity, unit, type=nil) @type = type set_optional_value(comparison, quantity, unit) end
Public Instance Methods
to_model()
click to toggle source
# File lib/model/types.rb, line 66 def to_model lm = low ? low.to_model : nil hm = high ? high.to_model : nil HQMF::Range.new(type, lm, hm, nil) end
Private Instance Methods
default_bounds_type()
click to toggle source
# File lib/model/types.rb, line 105 def default_bounds_type case type when 'IVL_TS' 'TS' else 'PQ' end end
set_optional_value(comparison, quantity, unit)
click to toggle source
# File lib/model/types.rb, line 74 def set_optional_value(comparison, quantity, unit) comparison_data = translate_comparison(comparison) value = Value.new(quantity, unit, comparison_data[:inclusive], default_bounds_type) case comparison_data[:high_or_low] when :high @high = value when :low @low = value when :both @high = value @low = value end end
translate_comparison(comparison)
click to toggle source
# File lib/model/types.rb, line 88 def translate_comparison(comparison) case comparison.downcase when 'less than or equal to' {high_or_low: :high, inclusive: true} when 'less than' {high_or_low: :high, inclusive: false} when 'greater than or equal to' {high_or_low: :low, inclusive: true} when 'greater than' {high_or_low: :low, inclusive: false} when 'equal to' {high_or_low: :both, inclusive: true} else raise "unknown mode for attribute: #{comparison}" end end