class Result
This is a class used to store the data of each scraped result in a central, easy to access location
Attributes
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Attribute Accessors declared for each piece of information collected from each result
Public Class Methods
provides access to the @@all class variable
# File lib/askoverflow/result.rb, line 40 def self.all @@all end
deletes all existing Result
instances used when additional searches are performed
# File lib/askoverflow/result.rb, line 36 def self.clear_results @@all.clear end
allows the user to access the results via human friendly indexing ie 1->10 not 0->9
# File lib/askoverflow/result.rb, line 24 def self.find_by_id(id) @@all[id.to_i - 1] end
uses metaprogramming and attribut accessors to assign the values of an initial hash to the instance's attributes, then shovels the instance onto @@all
# File lib/askoverflow/result.rb, line 16 def initialize(attributes) attributes.each do |s, v| self.send("#{s}=", v) end @@all << self end
Public Instance Methods
allows a result's scraped full Q&A to be added to the instance
# File lib/askoverflow/result.rb, line 29 def add_full(content_hash) content_hash.each do |s, v| self.send("#{s}=", v) end end