Class: SolrResults

Inherits:
Object
  • Object
show all
Defined in:
public/app/models/solr_results.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(solr_results, search_opts = {}, full = false) ⇒ SolrResults

Returns a new instance of SolrResults.



6
7
8
9
10
# File 'public/app/models/solr_results.rb', line 6

def initialize(solr_results, search_opts = {}, full = false)
  @raw = solr_results
  @records = parse_records(full)
  @search_opts = search_opts
end

Instance Attribute Details

#facetsObject (readonly)

Returns the value of attribute facets



4
5
6
# File 'public/app/models/solr_results.rb', line 4

def facets
  @facets
end

#rawObject (readonly)

Returns the value of attribute raw



4
5
6
# File 'public/app/models/solr_results.rb', line 4

def raw
  @raw
end

#recordsObject (readonly)

Returns the value of attribute records



4
5
6
# File 'public/app/models/solr_results.rb', line 4

def records
  @records
end

Instance Method Details

#[](k) ⇒ Object

while this is available it cannot be private Ruby 2.5+



21
22
23
24
# File 'public/app/models/solr_results.rb', line 21

def [](k)
  # $stderr.puts "FIXME stop direct access to the results json blob ([]): #{caller.first}"
  raw[k]
end

#empty?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'public/app/models/solr_results.rb', line 12

def empty?
  @raw['results'].blank? || @raw['results'].empty?
end

#firstObject



16
17
18
# File 'public/app/models/solr_results.rb', line 16

def first
  @records.first
end