Class: Sunspot::Query::Sort::FunctionComp

Inherits:
Object
  • Object
show all
Defined in:
lib/sunspot/query/sort.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(setup, args) ⇒ FunctionComp

Returns a new instance of FunctionComp.



134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/sunspot/query/sort.rb', line 134

def initialize(setup,args)
  @function=args.shift
  @fields = []
  args.each do |argument|
    case argument.class.name
    when "Array"
      @fields<< FunctionComp.new(setup,argument)
    when "Symbol"
      @fields<< setup.field(argument).indexed_name
    else
      @fields<< argument
    end
  end
end

Instance Attribute Details

#fieldsObject

Returns the value of attribute fields.



133
134
135
# File 'lib/sunspot/query/sort.rb', line 133

def fields
  @fields
end

#functionObject

Returns the value of attribute function.



133
134
135
# File 'lib/sunspot/query/sort.rb', line 133

def function
  @function
end

Instance Method Details

#to_sObject



148
149
150
# File 'lib/sunspot/query/sort.rb', line 148

def to_s
  "#{function}(#{fields.map(&:to_s).join(",")})"
end