Class: Epguides::Show
- Inherits:
-
Object
- Object
- Epguides::Show
- Defined in:
- lib/epguides/show.rb
Instance Attribute Summary collapse
-
#slug ⇒ Object
readonly
Returns the value of attribute slug.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
- #episodes ⇒ Object
-
#initialize(args = {}) ⇒ Show
constructor
A new instance of Show.
- #name ⇒ Object
- #season(n) ⇒ Object
- #seasons ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Show
Returns a new instance of Show.
11 12 13 14 |
# File 'lib/epguides/show.rb', line 11 def initialize(args={}) @slug = args[:slug] @url = args[:url] end |
Instance Attribute Details
#slug ⇒ Object (readonly)
Returns the value of attribute slug.
9 10 11 |
# File 'lib/epguides/show.rb', line 9 def slug @slug end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/epguides/show.rb', line 9 def url @url end |
Class Method Details
.search(q) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/epguides/show.rb', line 46 def self.search(q) search_url = 'http://ajax.googleapis.com/ajax/services/search/web' + '?v=1.0&q=allintitle: site:epguides.com ' results = JSON.parse RestClient.get(URI.escape(search_url + q)) new url: results['responseData']['results'].first['url'] end |
Instance Method Details
#episodes ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/epguides/show.rb', line 16 def episodes return @episodes if @episodes @episodes = EpisodeList.new parse_table.each do |row| if m = Episode::REGX.match(row) @episodes << Episode.new(m[2], m[3], m[4], m[5], m[6]) end end @episodes end |
#name ⇒ Object
27 28 29 |
# File 'lib/epguides/show.rb', line 27 def name doc.css('//h1').text end |