Class: NewOpportunities::Opportunities
- Inherits:
-
Object
- Object
- NewOpportunities::Opportunities
- Defined in:
- lib/new-opportunities/opportunity.rb
Instance Attribute Summary collapse
-
#deadline ⇒ Object
Returns the value of attribute deadline.
-
#description ⇒ Object
Returns the value of attribute description.
-
#name ⇒ Object
Returns the value of attribute name.
-
#post_date ⇒ Object
Returns the value of attribute post_date.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Attribute Details
#deadline ⇒ Object
Returns the value of attribute deadline.
3 4 5 |
# File 'lib/new-opportunities/opportunity.rb', line 3 def deadline @deadline end |
#description ⇒ Object
Returns the value of attribute description.
3 4 5 |
# File 'lib/new-opportunities/opportunity.rb', line 3 def description @description end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/new-opportunities/opportunity.rb', line 3 def name @name end |
#post_date ⇒ Object
Returns the value of attribute post_date.
3 4 5 |
# File 'lib/new-opportunities/opportunity.rb', line 3 def post_date @post_date end |
#url ⇒ Object
Returns the value of attribute url.
3 4 5 |
# File 'lib/new-opportunities/opportunity.rb', line 3 def url @url end |
Class Method Details
.all ⇒ Object
7 8 9 |
# File 'lib/new-opportunities/opportunity.rb', line 7 def self.all @opportunities end |
.scrape ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/new-opportunities/opportunity.rb', line 12 def self.scrape html = Nokogiri::HTML(open("http://oppourtunities.com/updates/")) html.css("article.post").each do |post| opportunity = NewOpportunities::Opportunities.new opportunity.name = post.css("h4 a").text.strip opportunity.url = post.css("h4 a").attr("href").value opportunity.description = post.css("p.eltdf-post-excerpt").text.strip.gsub("\r\n", " ").split(" ")[4..-1].join(" ") opportunity.post_date = post.css(".entry-date a").text.strip opportunity.deadline = post.css("p.eltdf-post-excerpt").text.strip.gsub("\r\n", " ").split(" ")[0..3].join(" ") self.all << opportunity end end |