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.
82 83 84 85 86 87 88 |
# File 'lib/dnz/facet.rb', line 82 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.
80 81 82 |
# File 'lib/dnz/facet.rb', line 80 def count @count end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
80 81 82 |
# File 'lib/dnz/facet.rb', line 80 def name @name end |
Instance Method Details
#inspect ⇒ Object
98 99 100 |
# File 'lib/dnz/facet.rb', line 98 def inspect {:name => self.name, :count => self.count}.inspect end |
#search(text = @search_text, options = {}) ⇒ Object
94 95 96 |
# File 'lib/dnz/facet.rb', line 94 def search(text = @search_text, = {}) @client.search('%s:%s %s' % [@facet.name, self.name, text], ) end |
#to_s ⇒ Object
102 103 104 |
# File 'lib/dnz/facet.rb', line 102 def to_s '%s => %d' % [self.name, self.count] end |
#valid? ⇒ Boolean
90 91 92 |
# File 'lib/dnz/facet.rb', line 90 def valid? !self.name.blank? end |