Class: TokyoEvents::Event
- Inherits:
-
Object
- Object
- TokyoEvents::Event
- Defined in:
- lib/tokyo_events/event.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#dates ⇒ Object
Returns the value of attribute dates.
-
#description ⇒ Object
Returns the value of attribute description.
-
#location ⇒ Object
Returns the value of attribute location.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(name, dates, url) ⇒ Event
constructor
A new instance of Event.
Constructor Details
#initialize(name, dates, url) ⇒ Event
Returns a new instance of Event.
10 11 12 13 14 15 16 |
# File 'lib/tokyo_events/event.rb', line 10 def initialize(name, dates, url) @name = name @dates = dates @url = url @@all << self end |
Instance Attribute Details
#dates ⇒ Object
Returns the value of attribute dates.
6 7 8 |
# File 'lib/tokyo_events/event.rb', line 6 def dates @dates end |
#description ⇒ Object
Returns the value of attribute description.
6 7 8 |
# File 'lib/tokyo_events/event.rb', line 6 def description @description end |
#location ⇒ Object
Returns the value of attribute location.
6 7 8 |
# File 'lib/tokyo_events/event.rb', line 6 def location @location end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/tokyo_events/event.rb', line 6 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
6 7 8 |
# File 'lib/tokyo_events/event.rb', line 6 def url @url end |
Class Method Details
.all ⇒ Object
35 36 37 |
# File 'lib/tokyo_events/event.rb', line 35 def self.all @@all end |
.find(id) ⇒ Object
39 40 41 |
# File 'lib/tokyo_events/event.rb', line 39 def self.find(id) self.all[id-1] end |
.find_by_name(name) ⇒ Object
43 44 45 46 47 |
# File 'lib/tokyo_events/event.rb', line 43 def self.find_by_name(name) self.all.select do |event| event.name.downcase.strip.include?(name.downcase.strip) end end |
.new_from_index_page(event) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/tokyo_events/event.rb', line 18 def self.new_from_index_page(event) self.new( event.css("a").text, event.css(".box_detail_ttl p").text, "https://www.gotokyo.org" + event.css("a").attribute("href").value ) end |
Instance Method Details
#doc ⇒ Object
49 50 51 |
# File 'lib/tokyo_events/event.rb', line 49 def doc @doc ||= Nokogiri::HTML(open(self.url)) end |