Class: FreeArtExhibits::Exhibit
- Inherits:
-
Object
- Object
- FreeArtExhibits::Exhibit
- Defined in:
- lib/free_art_exhibits/exhibit.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #address ⇒ Object
- #details_page ⇒ Object
-
#initialize(url, title, description) ⇒ Exhibit
constructor
def self.new_from_index_page(exhibit) self.new( “www.timeout.com” + exhibit.css(“a.read-more”).attr(“href”).value + “#tab_panel_2”, exhibit.css(“h3 a”).text, exhibit.css(“p.feature_item__annotation–truncated”).text ) end.
- #opening_hours ⇒ Object
- #venue_name ⇒ Object
Constructor Details
#initialize(url, title, description) ⇒ Exhibit
def self.new_from_index_page(exhibit)
self.new(
"http://www.timeout.com" + exhibit.css("a.read-more").attr("href").value + "#tab_panel_2",
exhibit.css("h3 a").text,
exhibit.css("p.feature_item__annotation--truncated").text
)
end
15 16 17 18 19 20 |
# File 'lib/free_art_exhibits/exhibit.rb', line 15 def initialize(url, title, description) @url = url @title = title @description = description @@all << self end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
4 5 6 |
# File 'lib/free_art_exhibits/exhibit.rb', line 4 def description @description end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/free_art_exhibits/exhibit.rb', line 4 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/free_art_exhibits/exhibit.rb', line 4 def url @url end |
Class Method Details
.all ⇒ Object
22 23 24 |
# File 'lib/free_art_exhibits/exhibit.rb', line 22 def self.all @@all end |
.find(id) ⇒ Object
26 27 28 |
# File 'lib/free_art_exhibits/exhibit.rb', line 26 def self.find(id) self.all[id-1] end |
Instance Method Details
#address ⇒ Object
40 41 42 43 44 45 |
# File 'lib/free_art_exhibits/exhibit.rb', line 40 def address string = "\n" self.details_page.css("tr td").select do |cell| cell.text + string + cell.css("br").first.text if cell.text.include?("<br>") end.first end |
#details_page ⇒ Object
47 48 49 |
# File 'lib/free_art_exhibits/exhibit.rb', line 47 def details_page @details_page ||= Nokogiri::HTML(open(self.url)) end |
#opening_hours ⇒ Object
34 35 36 37 38 |
# File 'lib/free_art_exhibits/exhibit.rb', line 34 def opening_hours self.details_page.css("tbody td").select do |cell| cell.text if cell.text.include?("pm") || cell.text.include?("am") end.first end |
#venue_name ⇒ Object
30 31 32 |
# File 'lib/free_art_exhibits/exhibit.rb', line 30 def venue_name self.details_page.css("td a").first.text end |