class MarkLogic::Queries::RangeQuery

Attributes

name[RW]
range_type[RW]

Public Class Methods

new(name, operator, range_type, value, options = {}) click to toggle source
# File lib/marklogic/queries/range_query.rb, line 7
def initialize(name, operator, range_type, value, options = {})
  @name = name.to_s
  @operator = operator.to_s.upcase
  @range_type = range_type
  @value = value
  @options = options || {}
  @weight = @options.delete(:weight) || 1.0
end

Public Instance Methods

operator() click to toggle source
# File lib/marklogic/queries/range_query.rb, line 20
def operator
  case @operator
    when "LT"
      "<"
    when "LE"
      "<="
    when "GT"
      ">"
    when "GE"
      ">="
    when "EQ"
      "="
    when "NE"
      "!="
    else
      @operator
  end
end
operator=(op) click to toggle source
# File lib/marklogic/queries/range_query.rb, line 16
def operator=(op)
  @operator = op
end
options() click to toggle source
# File lib/marklogic/queries/range_query.rb, line 43
def options
  opts = []
  @options.each do |k, v|
    case k.to_s
    when "collation", "min_occurs", "max_occurs", "score_function", "slope_factor"
      opts << %Q{"#{k.to_s.gsub(/_/, '-')}=#{v}"}
    when "cached"
      opts << (v == true ? %Q{"cached"} : %Q{"uncached"})
    when "synonym"
      opts << %Q{"#{k}"}
    else
      opts << %Q{"#{v}"}
    end
  end

  opts
end
options=(opts) click to toggle source
# File lib/marklogic/queries/range_query.rb, line 39
def options=(opts)
  @options = opts
end
to_xqy() click to toggle source
# File lib/marklogic/queries/range_query.rb, line 61
def to_xqy
  value = query_value(@value, @range_type)
  %Q{cts:json-property-range-query("#{@name}","#{operator}",(#{value}),(#{options.join(',')}),#{@weight})}
end