Class: HQMF::SubsetOperator

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

Constant Summary collapse

TYPES =
['COUNT', 'FIRST', 'SECOND', 'THIRD', 'FOURTH', 'FIFTH', 'RECENT', 'LAST', 'MIN', 'MAX', 'DATEDIFF', 'TIMEDIFF', 'DATETIMEDIFF', 'MEDIAN', 'MEAN', 'SUM']

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, value) ⇒ SubsetOperator

Returns a new instance of SubsetOperator.

Parameters:



271
272
273
274
275
276
277
278
279
# File 'lib/hqmf-model/types.rb', line 271

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

Instance Attribute Details

#typeObject

Returns the value of attribute type.



268
269
270
# File 'lib/hqmf-model/types.rb', line 268

def type
  @type
end

#valueObject

Returns the value of attribute value.



268
269
270
# File 'lib/hqmf-model/types.rb', line 268

def value
  @value
end

Class Method Details

.from_json(json) ⇒ Object



285
286
287
288
289
# File 'lib/hqmf-model/types.rb', line 285

def self.from_json(json)
  type = json["type"] if json["type"]
  value = HQMF::DataCriteria.convert_value(json["value"]) if json["value"]  
  HQMF::SubsetOperator.new(type,value)
end

Instance Method Details

#==(other) ⇒ Object



298
299
300
# File 'lib/hqmf-model/types.rb', line 298

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

#supports_grouper_criteria?Boolean

Returns:

  • (Boolean)


281
282
283
# File 'lib/hqmf-model/types.rb', line 281

def supports_grouper_criteria?
  ['FIRST', 'SECOND', 'THIRD', 'FOURTH', 'FIFTH', 'RECENT', 'LAST'].include? @type
end

#to_jsonObject



292
293
294
295
296
# File 'lib/hqmf-model/types.rb', line 292

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