Class: CqlRuby::CqlSortNode

Inherits:
CqlNode
  • Object
show all
Defined in:
lib/cql_ruby/cql_nodes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CqlNode

#check_xml, #getResultSetName, #render_prefixes, #render_sortkeys, #to_solr

Constructor Details

#initialize(subtree) ⇒ CqlSortNode

Returns a new instance of CqlSortNode.



296
297
298
299
300
# File 'lib/cql_ruby/cql_nodes.rb', line 296

def initialize( subtree )
  super()
  @subtree = subtree
  @keys = []
end

Instance Attribute Details

#keysObject

Returns the value of attribute keys.



294
295
296
# File 'lib/cql_ruby/cql_nodes.rb', line 294

def keys
  @keys
end

#subtreeObject

Returns the value of attribute subtree.



294
295
296
# File 'lib/cql_ruby/cql_nodes.rb', line 294

def subtree
  @subtree
end

Instance Method Details

#add_sort_index(key) ⇒ Object



302
303
304
# File 'lib/cql_ruby/cql_nodes.rb', line 302

def add_sort_index( key )
  @keys << key
end

#to_cqlObject



313
314
315
316
317
318
319
320
321
322
# File 'lib/cql_ruby/cql_nodes.rb', line 313

def to_cql
  buf = @subtree.to_cql
  if @keys.any?
    buf << " sortby "
    @keys.each do |key|
      buf << " #{key.to_cql}"
    end
  end
  buf
end

#to_xcql(xml = nil, prefixes = nil, sortkeys = nil) ⇒ Object

Raises:



306
307
308
309
310
311
# File 'lib/cql_ruby/cql_nodes.rb', line 306

def to_xcql( xml=nil, prefixes=nil, sortkeys=nil )
  raise CqlException,  "CqlSortNode.to_xcql called with sortkeys" if sortkeys and sortkeys.any?

  xml = check_xml( xml )
  return @subtree.to_xcql( xml, prefixes, @keys )
end