Class: FederalRegister::FacetResultSet
- Includes:
- Enumerable
- Defined in:
- lib/federal_register/facet_result_set.rb
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Class Method Summary collapse
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(attributes, result_class, options = {}) ⇒ FacetResultSet
constructor
A new instance of FacetResultSet.
Methods inherited from Client
Constructor Details
#initialize(attributes, result_class, options = {}) ⇒ FacetResultSet
Returns a new instance of FacetResultSet.
6 7 8 9 10 11 12 13 14 |
# File 'lib/federal_register/facet_result_set.rb', line 6 def initialize(attributes, result_class, ={}) @result_class = result_class @conditions = [:query] || {} @results = (attributes || {}).map do |slug, attributes| attributes["slug"] = slug @result_class.new(attributes, .merge(:result_set => self) ) end end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
4 5 6 |
# File 'lib/federal_register/facet_result_set.rb', line 4 def conditions @conditions end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
4 5 6 |
# File 'lib/federal_register/facet_result_set.rb', line 4 def results @results end |
Class Method Details
.fetch(url, options = {}) ⇒ Object
16 17 18 19 20 |
# File 'lib/federal_register/facet_result_set.rb', line 16 def self.fetch(url, = {}) result_class = .delete(:result_class) response = get(url, ).parsed_response new(response, result_class, ) end |
Instance Method Details
#each ⇒ Object
22 23 24 |
# File 'lib/federal_register/facet_result_set.rb', line 22 def each @results.each {|result| yield result } end |