Class: CheapSkate::ResultSet
- Inherits:
-
Object
- Object
- CheapSkate::ResultSet
- Defined in:
- lib/cheap_skate/models.rb
Instance Attribute Summary collapse
-
#docs ⇒ Object
Returns the value of attribute docs.
-
#facets ⇒ Object
Returns the value of attribute facets.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#max_score ⇒ Object
Returns the value of attribute max_score.
-
#nl_format ⇒ Object
Returns the value of attribute nl_format.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#query ⇒ Object
Returns the value of attribute query.
-
#query_time ⇒ Object
Returns the value of attribute query_time.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
Instance Attribute Details
#docs ⇒ Object
Returns the value of attribute docs.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def docs @docs end |
#facets ⇒ Object
Returns the value of attribute facets.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def facets @facets end |
#limit ⇒ Object
Returns the value of attribute limit.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def limit @limit end |
#max_score ⇒ Object
Returns the value of attribute max_score.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def max_score @max_score end |
#nl_format ⇒ Object
Returns the value of attribute nl_format.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def nl_format @nl_format end |
#offset ⇒ Object
Returns the value of attribute offset.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def offset @offset end |
#query ⇒ Object
Returns the value of attribute query.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def query @query end |
#query_time ⇒ Object
Returns the value of attribute query_time.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def query_time @query_time end |
#total ⇒ Object
Returns the value of attribute total.
29 30 31 |
# File 'lib/cheap_skate/models.rb', line 29 def total @total end |
Instance Method Details
#<<(obj) ⇒ Object
30 31 32 33 |
# File 'lib/cheap_skate/models.rb', line 30 def <<(obj) @docs ||=[] @docs << obj end |
#as_json ⇒ Object
53 54 55 56 57 |
# File 'lib/cheap_skate/models.rb', line 53 def as_json response = self.to_hash response["responseHeader"]["wt"] = "json" response.to_json end |
#as_ruby ⇒ Object
48 49 50 51 52 |
# File 'lib/cheap_skate/models.rb', line 48 def as_ruby response = self.to_hash response["responseHeader"]["wt"] = "ruby" response.inspect end |
#to_hash ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/cheap_skate/models.rb', line 35 def to_hash() response = {"responseHeader"=>{"status"=>0, "QTime"=>self.query_time, "params"=>{"q"=>self.query, "version"=>"2.2", "rows"=>self.limit}}} response["response"] = {"numFound"=>self.total, "start"=>self.offset, "rows"=>(self.docs||[]).length, "docs"=>[]} response["response"]["maxScore"] = self.max_score if self.max_score if self.docs self.docs.each do |doc| response["response"]["docs"] << doc end end response end |