Class: DNZ::FacetValue

Inherits:
Object
  • Object
show all
Defined in:
lib/dnz/facet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#countObject (readonly)

Returns the value of attribute count.



80
81
82
# File 'lib/dnz/facet.rb', line 80

def count
  @count
end

#nameObject (readonly)

Returns the value of attribute name.



80
81
82
# File 'lib/dnz/facet.rb', line 80

def name
  @name
end

Instance Method Details

#inspectObject



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, options = {})
  @client.search('%s:%s %s' % [@facet.name, self.name, text], options)
end

#to_sObject



102
103
104
# File 'lib/dnz/facet.rb', line 102

def to_s
  '%s => %d' % [self.name, self.count]
end

#valid?Boolean

Returns:

  • (Boolean)


90
91
92
# File 'lib/dnz/facet.rb', line 90

def valid?
  !self.name.blank?
end