class HQMF1::Expression
Attributes
text[R]
type[R]
value[R]
Public Class Methods
new(entry)
click to toggle source
# File lib/hqmf-parser/1.0/expression.rb, line 9 def initialize(entry) @entry = entry @text = @entry.xpath('./*/cda:derivationExpr').text.strip type = attr_val('./*/cda:value/@xsi:type') case type when 'IVL_PQ' @value = Range.new(@entry.xpath('./*/cda:value')) when 'PQ' @value = Value.new(@entry.xpath('./*/cda:value')) when 'ANYNonNull' @value = HQMF::AnyValue.new when nil @value = HQMF::AnyValue.new else raise "Unknown expression value type #{type}" end @type = match_type end
Public Instance Methods
match_type()
click to toggle source
# File lib/hqmf-parser/1.0/expression.rb, line 28 def match_type case @text when /^COUNT(.*)$/ "COUNT" when /^MIN(.*)$/ "MIN" when /^MAX(.*)$/ "MAX" when /^DATEDIFF(.*)$/ "DATEDIFF" when /^TIMEDIFF(.*)$/ "TIMEDIFF" when /^MEDIAN(.*)$/ "MEDIAN" when /^AVG(.*)$/ "MEAN" else raise "unknown expression type: #{@text}" end end
to_json()
click to toggle source
# File lib/hqmf-parser/1.0/expression.rb, line 49 def to_json json = build_hash(self, [:text,:type]) json[:value] = self.value.to_json if self.value json end