Class: HQMF::TemporalReference

Inherits:
Object
  • Object
show all
Includes:
Conversion::Utilities
Defined in:
lib/hqmf-model/types.rb

Constant Summary collapse

TYPES =
['DURING','OVERLAP','SBS','SAS','SBE','SAE','EBS','EAS','EBE','EAE','SDU','EDU','ECW','SCW','ECWS','SCWE','SBCW','SBCWE','SACW','SACWE','SBDU','EBCW','EBCWS','EACW','EACWS','EADU','CONCURRENT']
INVERSION =
{'SBS' => 'SAS','EAE' => 'EBE','SAS' => 'SBS','EBE' => 'EAE','SBE' => 'EAS','EAS' => 'SBE','SAE' => 'EBS','EBS' => 'SAE'}

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, reference, range) ⇒ TemporalReference

Returns a new instance of TemporalReference.

Parameters:



231
232
233
234
235
236
237
238
239
# File 'lib/hqmf-model/types.rb', line 231

def initialize(type, reference, range)
  @type = type
  @reference = reference
  if (range.is_a? HQMF::Value)
    @range = HQMF::Range.new('IVL_PQ', range, range, nil)
  else
    @range = range
  end
end

Instance Attribute Details

#rangeObject (readonly)

Returns the value of attribute range.



226
227
228
# File 'lib/hqmf-model/types.rb', line 226

def range
  @range
end

#referenceObject (readonly)

Returns the value of attribute reference.



226
227
228
# File 'lib/hqmf-model/types.rb', line 226

def reference
  @reference
end

#typeObject (readonly)

Returns the value of attribute type.



226
227
228
# File 'lib/hqmf-model/types.rb', line 226

def type
  @type
end

Class Method Details

.from_json(json) ⇒ Object



241
242
243
244
245
246
247
# File 'lib/hqmf-model/types.rb', line 241

def self.from_json(json)
  type = json["type"] if json["type"]
  reference = HQMF::Reference.new(json["reference"]) if json["reference"]
  range = HQMF::Range.from_json(json["range"]) if json["range"]
  
  HQMF::TemporalReference.new(type,reference,range)
end

Instance Method Details

#==(other) ⇒ Object



257
258
259
# File 'lib/hqmf-model/types.rb', line 257

def ==(other)
  check_equality(self,other)
end

#to_jsonObject



250
251
252
253
254
255
# File 'lib/hqmf-model/types.rb', line 250

def to_json
  json = build_hash(self, [:type])
  json[:reference] = @reference.to_json if @reference
  json[:range] = @range.to_json if @range
  json
end