class HQMF::Converter::SimpleOperator
Constants
- SUMMARY
- TEMPORAL
- UNKNOWN
- VALUE_FIELD_TIMES
Attributes
category[RW]
field[RW]
field_code[RW]
field_time[RW]
type[RW]
value[RW]
Public Class Methods
find_category(type)
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 72 def self.find_category(type) return TEMPORAL if HQMF::TemporalReference::TYPES.include? type return SUMMARY if HQMF::SubsetOperator::TYPES.include? type return UNKNOWN end
new(category, type, value, field = nil, field_code=nil, field_time=nil)
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 19 def initialize(category, type, value, field = nil, field_code=nil, field_time=nil) @category = category @type = type @value = value @field = field @field_code = field_code @field_time = field_time end
parse_value(value)
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 52 def self.parse_value(value) return nil unless value return value if value.is_a? String if (value[:value]) # values should be inclusive since we will be asking if it equals the value, ranther than being part of a range # if it's an offset we do not care that it is inclusive val = HQMF::Value.from_json(JSON.parse(value.to_json)) val.inclusive=true val elsif (value[:high] or value[:low]) HQMF::Range.from_json(JSON.parse(value.to_json)) elsif (value[:type] == 'CD') HQMF::Coded.from_json(JSON.parse(value.to_json)) elsif (value[:type] == 'ANYNonNull') HQMF::AnyValue.from_json(JSON.parse(value.to_json)) else raise "Unexpected value format: #{value.to_json}" end end
Public Instance Methods
field_value_key()
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 45 def field_value_key key = HQMF::DataCriteria::VALUE_FIELDS[field_code] key = VALUE_FIELD_TIMES["#{key}_#{field_time.to_s.upcase}"] if (field_time) raise "unsupported field value: #{field_code}, #{field}" unless key key end
summary?()
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 31 def summary? category == SUMMARY end
temporal?()
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 28 def temporal? category == TEMPORAL end
to_json()
click to toggle source
# File lib/hqmf-parser/converter/pass1/simple_operator.rb, line 35 def to_json json = {} json[:category] = @category if @category json[:type] = @type if @type json[:field] = @field if @field json[:field_code] = @field_code if @field_code json[:value] = @value.to_json if @value json end