Class: Songle::SongURI::YtSongURI
- Inherits:
-
Object
- Object
- Songle::SongURI::YtSongURI
- Includes:
- Songle::SongURI
- Defined in:
- lib/songle/song_uri/yt_song_uri.rb
Constant Summary collapse
- SOURCE_HOST =
"www.youtube.com"- SOURCE_PATH =
"/watch?v="- TYPE =
"youtube"- URI_REGEXP =
/#{ SOURCE_HOST.gsub("www.", "") }(#{ SOURCE_PATH.gsub("?", "\\?") }(.+))/
Constants included from Songle::SongURI
ENDPOINT_HOST, ENDPOINT_PATH, ENDPOINT_SCHEME
Instance Attribute Summary
Attributes included from Songle::SongURI
#endpoint_host, #endpoint_path, #endpoint_scheme, #source_host, #source_id, #source_path
Instance Method Summary collapse
-
#initialize(query_string, options) ⇒ YtSongURI
constructor
A new instance of YtSongURI.
- #type ⇒ Object
Methods included from Songle::SongURI
#endpoint, parse, #permalink, #to_s
Constructor Details
#initialize(query_string, options) ⇒ YtSongURI
Returns a new instance of YtSongURI.
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/songle/song_uri/yt_song_uri.rb', line 28 def initialize query_string, super() @source_host = SOURCE_HOST @source_path = $1 if query_string =~ URI_REGEXP @source_id = $2 if query_string =~ URI_REGEXP if @source_id.nil? || @source_id.strip.empty? raise ::Songle::SongURI::InvalidSongURIError.new(query_string) end end |
Instance Method Details
#type ⇒ Object
43 44 45 |
# File 'lib/songle/song_uri/yt_song_uri.rb', line 43 def type return TYPE end |