Module: VkMusic::Utility::PostUrlParser

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

Overview

Load wall audios

Constant Summary collapse

POST_POSTFIX =

Regex for post URL

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

Class Method Summary collapse

Class Method Details

.call(url) ⇒ Array(owner_id?, post_id?)

Parameters:

  • url (String)

Returns:

  • (Array(owner_id?, post_id?))


13
14
15
16
17
18
19
20
21
# File 'lib/vk_music/utility/post_url_parser.rb', line 13

def self.call(url)
  matches = url.match(POST_POSTFIX)&.captures
  return [nil, nil] unless matches && matches.size == 2

  owner_id = Integer(matches[0], 10)
  post_id = Integer(matches[1], 10)

  [owner_id, post_id]
end