Class: DNZ::FacetValue
- Inherits:
-
Object
- Object
- DNZ::FacetValue
- Defined in:
- lib/dnz/facet.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(client, facet, doc) ⇒ FacetValue
constructor
A new instance of FacetValue.
- #inspect ⇒ Object
- #search(text = @search_text, options = {}) ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(client, facet, doc) ⇒ FacetValue
Returns a new instance of FacetValue.
35 36 37 38 39 40 41 |
# File 'lib/dnz/facet.rb', line 35 def initialize(client, facet, doc) @client = client @facet = facet @search_text = facet.search.text @name = doc.xpath('name').text @count = doc.xpath('num-results').text.to_i end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
33 34 35 |
# File 'lib/dnz/facet.rb', line 33 def count @count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/dnz/facet.rb', line 33 def name @name end |
Instance Method Details
#inspect ⇒ Object
51 52 53 |
# File 'lib/dnz/facet.rb', line 51 def inspect {:name => self.name, :count => self.count}.inspect end |
#search(text = @search_text, options = {}) ⇒ Object
47 48 49 |
# File 'lib/dnz/facet.rb', line 47 def search(text = @search_text, = {}) @client.search('%s:%s %s' % [@facet.name, self.name, text], ) end |
#to_s ⇒ Object
55 56 57 |
# File 'lib/dnz/facet.rb', line 55 def to_s self.name end |
#valid? ⇒ Boolean
43 44 45 |
# File 'lib/dnz/facet.rb', line 43 def valid? !self.name.blank? end |