Class: TheatreCliGem::Show

Inherits:
Object
  • Object
show all
Defined in:
lib/theatre_cli_gem/show.rb

Constant Summary collapse

@@all =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/theatre_cli_gem/show.rb', line 2

def name
  @name
end

#showdocObject

Returns the value of attribute showdoc.



2
3
4
# File 'lib/theatre_cli_gem/show.rb', line 2

def showdoc
  @showdoc
end

#summaryObject

Returns the value of attribute summary.



2
3
4
# File 'lib/theatre_cli_gem/show.rb', line 2

def summary
  @summary
end

#theaterObject

Returns the value of attribute theater.



2
3
4
# File 'lib/theatre_cli_gem/show.rb', line 2

def theater
  @theater
end

#urlObject

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

.allObject



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_showsObject



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