Class: HQMF::Value
- Inherits:
-
Object
- Object
- HQMF::Value
- Includes:
- Conversion::Utilities
- Defined in:
- lib/hqmf-model/types.rb
Overview
Represents a bound within a HQMF pauseQuantity, has a value, a unit and an inclusive/exclusive indicator
Instance Attribute Summary collapse
-
#expression ⇒ Object
readonly
Returns the value of attribute expression.
-
#inclusive ⇒ Object
Returns the value of attribute inclusive.
-
#type ⇒ Object
Returns the value of attribute type.
-
#unit ⇒ Object
readonly
Returns the value of attribute unit.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #derived? ⇒ Boolean
- #inclusive? ⇒ Boolean
-
#initialize(type, unit, value, inclusive, derived, expression) ⇒ Value
constructor
Create a new HQMF::Value.
- #stringify ⇒ Object
- #to_json ⇒ Object
Methods included from Conversion::Utilities
#build_hash, #check_equality, #json_array, #openstruct_to_json
Constructor Details
#initialize(type, unit, value, inclusive, derived, expression) ⇒ Value
Create a new HQMF::Value
42 43 44 45 46 47 48 49 |
# File 'lib/hqmf-model/types.rb', line 42 def initialize(type,unit,value,inclusive,derived,expression) @type = type || 'PQ' @unit = unit @value = value @inclusive = inclusive == nil ? true : inclusive @derived = derived || false @expression = expression end |
Instance Attribute Details
#expression ⇒ Object (readonly)
Returns the value of attribute expression.
32 33 34 |
# File 'lib/hqmf-model/types.rb', line 32 def expression @expression end |
#inclusive ⇒ Object
Returns the value of attribute inclusive.
33 34 35 |
# File 'lib/hqmf-model/types.rb', line 33 def inclusive @inclusive end |
#type ⇒ Object
Returns the value of attribute type.
33 34 35 |
# File 'lib/hqmf-model/types.rb', line 33 def type @type end |
#unit ⇒ Object (readonly)
Returns the value of attribute unit.
32 33 34 |
# File 'lib/hqmf-model/types.rb', line 32 def unit @unit end |
#value ⇒ Object
Returns the value of attribute value.
33 34 35 |
# File 'lib/hqmf-model/types.rb', line 33 def value @value end |
Class Method Details
.from_json(json) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hqmf-model/types.rb', line 51 def self.from_json(json) type = json["type"] if json["type"] unit = json["unit"] if json["unit"] value = json["value"] if json["value"] inclusive = json["inclusive?"] unless json["inclusive?"].nil? derived = json["derived?"] unless json["derived?"].nil? expression = json["expression"] if json["expression"] HQMF::Value.new(type,unit,value,inclusive,derived,expression) end |
Instance Method Details
#==(other) ⇒ Object
79 80 81 |
# File 'lib/hqmf-model/types.rb', line 79 def ==(other) check_equality(self,other) end |
#derived? ⇒ Boolean
67 68 69 |
# File 'lib/hqmf-model/types.rb', line 67 def derived? @derived end |
#inclusive? ⇒ Boolean
63 64 65 |
# File 'lib/hqmf-model/types.rb', line 63 def inclusive? @inclusive end |
#stringify ⇒ Object
75 76 77 |
# File 'lib/hqmf-model/types.rb', line 75 def stringify "#{inclusive? ? '=' : ''}#{value}#{unit ? ' '+unit : ''}" end |
#to_json ⇒ Object
71 72 73 |
# File 'lib/hqmf-model/types.rb', line 71 def to_json build_hash(self, [:type,:unit,:value,:inclusive?,:derived?,:expression]) end |