Module: VkMusic::Utility::DataTypeGuesser

Defined in:
lib/vk_music/utility/data_type_guesser.rb

Overview

Guess type of method to use based on string data

Constant Summary collapse

PLAYLIST_POSTFIX =

End of playlist URL

PlaylistUrlParser::VK_PLAYLIST_URL_POSTFIX
ARTIST_POSTFIX =

Artist URL postfix

ArtistUrlParser::ARTIST_POSTFIX
POST_POSTFIX =

End of post URL

PostUrlParser::POST_POSTFIX
WALL_POSTFIX =

End of wall URL

/.*wall(-?\d+)/.freeze
AUDIOS_POSTFIX =

End of profile audios URL

/.*audios(-?\d+)/.freeze
PROFILE_URL =

Full profile URL regex

%r{(?:https?://)?(?:vk\.com/)([^/?&]+)}.freeze

Class Method Summary collapse

Class Method Details

.call(data) ⇒ Symbol

Parameters:

  • data (String)

Returns:

  • (Symbol)


37
38
39
40
41
42
43
44
45
46
# File 'lib/vk_music/utility/data_type_guesser.rb', line 37

def self.call(data)
  case data
  when PLAYLIST_POSTFIX then :playlist
  when ARTIST_POSTFIX then :artist
  when POST_POSTFIX then :post
  when WALL_POSTFIX then :wall
  when AUDIOS_POSTFIX, PROFILE_URL then :audios
  else :find
  end
end