class Result

This is a class used to store the data of each scraped result in a central, easy to access location

Attributes

all[RW]

Attribute Accessors declared for each piece of information collected from each result

answer_count[RW]

Attribute Accessors declared for each piece of information collected from each result

ask_date[RW]

Attribute Accessors declared for each piece of information collected from each result

author[RW]

Attribute Accessors declared for each piece of information collected from each result

full_a[RW]

Attribute Accessors declared for each piece of information collected from each result

full_q[RW]

Attribute Accessors declared for each piece of information collected from each result

id[RW]

Attribute Accessors declared for each piece of information collected from each result

question[RW]

Attribute Accessors declared for each piece of information collected from each result

sample[RW]

Attribute Accessors declared for each piece of information collected from each result

tags[RW]

Attribute Accessors declared for each piece of information collected from each result

Public Class Methods

all() click to toggle source

provides access to the @@all class variable

# File lib/askoverflow/result.rb, line 40
def self.all
    @@all
end
clear_results() click to toggle source

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
find_by_id(id) click to toggle source

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
new(attributes) click to toggle source

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

add_full(content_hash) click to toggle source

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