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.



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

#countObject (readonly)

Returns the value of attribute count.



33
34
35
# File 'lib/dnz/facet.rb', line 33

def count
  @count
end

#nameObject (readonly)

Returns the value of attribute name.



33
34
35
# File 'lib/dnz/facet.rb', line 33

def name
  @name
end

Instance Method Details

#inspectObject



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

#to_sObject



55
56
57
# File 'lib/dnz/facet.rb', line 55

def to_s
  self.name
end

#valid?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/dnz/facet.rb', line 43

def valid?
  !self.name.blank?
end