Class: WWW::VideoScraper::Base
- Inherits:
-
Object
- Object
- WWW::VideoScraper::Base
- Defined in:
- lib/www/video_scraper/base.rb
Direct Known Subclasses
AdultSatellites, AgeSage, AmebaVision, Dailymotion, EicBook, MoroTube, NicoVideo, Pornhub, Pornotube, RedTube, Tube8, Veoh, YouPorn, YouTube, YourFileHost
Instance Attribute Summary collapse
-
#embed_tag ⇒ Object
readonly
Returns the value of attribute embed_tag.
-
#page_url ⇒ Object
readonly
Returns the value of attribute page_url.
-
#thumb_url ⇒ Object
readonly
Returns the value of attribute thumb_url.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#video_url ⇒ Object
readonly
Returns the value of attribute video_url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url, opt = nil) ⇒ Base
constructor
A new instance of Base.
- #scrape ⇒ Object
Constructor Details
#initialize(url, opt = nil) ⇒ Base
Returns a new instance of Base.
32 33 34 35 36 37 38 39 40 |
# File 'lib/www/video_scraper/base.rb', line 32 def initialize(url, opt = nil) @page_url = url @opt = (opt || {}) url_regex = self.class.instance_variable_get(:@url_regex) Array(url_regex).any? do |r| @url_regex_match = r.match(@page_url).freeze end raise StandardError, "url is not #{self.class.name} link: #{url}" if @url_regex_match.nil? end |
Instance Attribute Details
#embed_tag ⇒ Object (readonly)
Returns the value of attribute embed_tag.
13 14 15 |
# File 'lib/www/video_scraper/base.rb', line 13 def end |
#page_url ⇒ Object (readonly)
Returns the value of attribute page_url.
13 14 15 |
# File 'lib/www/video_scraper/base.rb', line 13 def page_url @page_url end |
#thumb_url ⇒ Object (readonly)
Returns the value of attribute thumb_url.
13 14 15 |
# File 'lib/www/video_scraper/base.rb', line 13 def thumb_url @thumb_url end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
13 14 15 |
# File 'lib/www/video_scraper/base.rb', line 13 def title @title end |
#video_url ⇒ Object (readonly)
Returns the value of attribute video_url.
13 14 15 |
# File 'lib/www/video_scraper/base.rb', line 13 def video_url @video_url end |
Class Method Details
.scrape(url, opt = nil) ⇒ Object
25 26 27 28 29 |
# File 'lib/www/video_scraper/base.rb', line 25 def scrape(url, opt = nil) instance = self.new(url, opt) instance.scrape instance end |
.url_regex(regex) ⇒ Object
17 18 19 |
# File 'lib/www/video_scraper/base.rb', line 17 def url_regex(regex) @url_regex = regex end |
.valid_url?(url) ⇒ Boolean
21 22 23 |
# File 'lib/www/video_scraper/base.rb', line 21 def valid_url?(url) Array(@url_regex).any? { |r| r.match(url) } end |
Instance Method Details
#scrape ⇒ Object
42 43 44 |
# File 'lib/www/video_scraper/base.rb', line 42 def scrape raise StandardError, 'not implemented yet' end |