Class: Songle::SongURI::NnShortSongURI

Inherits:
Object
  • Object
show all
Includes:
Songle::SongURI
Defined in:
lib/songle/song_uri/nn_short_song_uri.rb

Constant Summary collapse

SOURCE_HOST =
::Songle::SongURI::NnSongURI::SOURCE_HOST
SOURCE_PATH =
::Songle::SongURI::NnSongURI::SOURCE_PATH
TYPE =
::Songle::SongURI::NnSongURI::TYPE
URI_REGEXP =
/nico\.ms\/(.+)$/

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

Methods included from Songle::SongURI

#endpoint, parse, #permalink, #to_s

Constructor Details

#initialize(query_string, options) ⇒ NnShortSongURI

Returns a new instance of NnShortSongURI.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/songle/song_uri/nn_short_song_uri.rb', line 28

def initialize query_string, options
  super(options)

  @source_host = SOURCE_HOST
  @source_path = SOURCE_PATH
  @source_id   = $1 if query_string =~ URI_REGEXP

  if @source_id.nil? || @source_id.strip.empty?
    raise ::Songle::SongURI::InvalidSongURIError.new(query_string)
  end

  @source_path += @source_id
end

Instance Method Details

#typeObject



45
46
47
# File 'lib/songle/song_uri/nn_short_song_uri.rb', line 45

def type
  return TYPE
end