Class: SeattleEvents::Events
- Inherits:
-
Object
- Object
- SeattleEvents::Events
- Defined in:
- lib/seattle_events/events.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rsvp_url ⇒ Object
Returns the value of attribute rsvp_url.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Events
constructor
A new instance of Events.
Constructor Details
#initialize(attributes = {}) ⇒ Events
Returns a new instance of Events.
5 6 7 8 9 10 11 |
# File 'lib/seattle_events/events.rb', line 5 def initialize(attributes = {}) @date = attributes[:date] @name = attributes[:name] @time = attributes[:time] @location = attributes[:location] @rsvp_url = attributes[:rsvp_url] end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
3 4 5 |
# File 'lib/seattle_events/events.rb', line 3 def date @date end |
#location ⇒ Object
Returns the value of attribute location.
3 4 5 |
# File 'lib/seattle_events/events.rb', line 3 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/seattle_events/events.rb', line 3 def name @name end |
#rsvp_url ⇒ Object
Returns the value of attribute rsvp_url.
3 4 5 |
# File 'lib/seattle_events/events.rb', line 3 def rsvp_url @rsvp_url end |
#time ⇒ Object
Returns the value of attribute time.
3 4 5 |
# File 'lib/seattle_events/events.rb', line 3 def time @time end |
Class Method Details
.all ⇒ Object
13 14 15 |
# File 'lib/seattle_events/events.rb', line 13 def self.all @@all ||= scrape_meetups end |
.scrape_meetups ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/seattle_events/events.rb', line 17 def self.scrape_meetups doc = Nokogiri::HTML(open("https://www.meetup.com/Learn-Code-Seattle/")) list_doc = doc.search("div#events-list-module li.line.event-item").to_a list_doc.collect.with_index do |event, i| name = doc.search("h3.flush--bottom a")[i].text unless doc.search("h3.flush--bottom a")[i] == nil self.new({ date: doc.search(".date")[i].text, name: name, time: doc.search("span.time")[i].text, location: doc.search("dt.event-venuename")[i].text.gsub(/[\n\t]/,""), rsvp_url: doc.search("li.rsvp-callout-outer a")[i].attr("href") }) end end |