Class: NewOpportunities::Opportunities

Inherits:
Object
  • Object
show all
Defined in:
lib/new-opportunities/opportunity.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#deadlineObject

Returns the value of attribute deadline.



3
4
5
# File 'lib/new-opportunities/opportunity.rb', line 3

def deadline
  @deadline
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/new-opportunities/opportunity.rb', line 3

def description
  @description
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/new-opportunities/opportunity.rb', line 3

def name
  @name
end

#post_dateObject

Returns the value of attribute post_date.



3
4
5
# File 'lib/new-opportunities/opportunity.rb', line 3

def 
  @post_date
end

#urlObject

Returns the value of attribute url.



3
4
5
# File 'lib/new-opportunities/opportunity.rb', line 3

def url
  @url
end

Class Method Details

.allObject



7
8
9
# File 'lib/new-opportunities/opportunity.rb', line 7

def self.all
  @opportunities
end

.scrapeObject



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.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