Class: HQMF::Value

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

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

Parameters:



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

#expressionObject (readonly)

Returns the value of attribute expression.



32
33
34
# File 'lib/hqmf-model/types.rb', line 32

def expression
  @expression
end

#inclusiveObject

Returns the value of attribute inclusive.



33
34
35
# File 'lib/hqmf-model/types.rb', line 33

def inclusive
  @inclusive
end

#typeObject

Returns the value of attribute type.



33
34
35
# File 'lib/hqmf-model/types.rb', line 33

def type
  @type
end

#unitObject (readonly)

Returns the value of attribute unit.



32
33
34
# File 'lib/hqmf-model/types.rb', line 32

def unit
  @unit
end

#valueObject

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

Returns:

  • (Boolean)


67
68
69
# File 'lib/hqmf-model/types.rb', line 67

def derived?
  @derived
end

#inclusive?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/hqmf-model/types.rb', line 63

def inclusive?
  @inclusive
end

#stringifyObject



75
76
77
# File 'lib/hqmf-model/types.rb', line 75

def stringify
  "#{inclusive? ? '=' : ''}#{value}#{unit ? ' '+unit : ''}"
end

#to_jsonObject



71
72
73
# File 'lib/hqmf-model/types.rb', line 71

def to_json
  build_hash(self, [:type,:unit,:value,:inclusive?,:derived?,:expression])
end