Class: TheatreCliGem::Show
- Inherits:
-
Object
- Object
- TheatreCliGem::Show
- Defined in:
- lib/theatre_cli_gem/show.rb
Constant Summary collapse
- @@all =
[]
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#showdoc ⇒ Object
Returns the value of attribute showdoc.
-
#summary ⇒ Object
Returns the value of attribute summary.
-
#theater ⇒ Object
Returns the value of attribute theater.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, url = nil) ⇒ Show
constructor
A new instance of Show.
Constructor Details
#initialize(name = nil, url = nil) ⇒ Show
Returns a new instance of Show.
5 6 7 8 9 |
# File 'lib/theatre_cli_gem/show.rb', line 5 def initialize(name=nil, url=nil) @name = name @url = url @@all << self end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/theatre_cli_gem/show.rb', line 2 def name @name end |
#showdoc ⇒ Object
Returns the value of attribute showdoc.
2 3 4 |
# File 'lib/theatre_cli_gem/show.rb', line 2 def showdoc @showdoc end |
#summary ⇒ Object
Returns the value of attribute summary.
2 3 4 |
# File 'lib/theatre_cli_gem/show.rb', line 2 def summary @summary end |
#theater ⇒ Object
Returns the value of attribute theater.
2 3 4 |
# File 'lib/theatre_cli_gem/show.rb', line 2 def theater @theater end |
#url ⇒ Object
Returns the value of attribute url.
2 3 4 |
# File 'lib/theatre_cli_gem/show.rb', line 2 def url @url end |
Class Method Details
.all ⇒ Object
11 12 13 |
# File 'lib/theatre_cli_gem/show.rb', line 11 def self.all @@all end |
.find(number) ⇒ Object
23 24 25 |
# File 'lib/theatre_cli_gem/show.rb', line 23 def self.find(number) self.all[number-1] end |
.scrape_shows ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/theatre_cli_gem/show.rb', line 15 def self.scrape_shows doc = Nokogiri::HTML(open("https://www.broadway.org/shows")) shows = doc.css("a.color-white.bold") shows.map do |show| self.new(show.text.strip, "https://www.broadway.org#{show.attr("href").strip}") end end |