Module: VkMusic::Utility::LastProfilePostLoader

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

Overview

Get user or group id from url

Class Method Summary collapse

Class Method Details

.call(agent, url: nil, owner_id: nil) ⇒ Array(owner_id?, post_id?)

Parameters:

  • agent (Mechanize)
  • url (String) (defaults to: nil)

    URL to profile page

Returns:

  • (Array(owner_id?, post_id?))


16
17
18
19
20
21
22
23
# File 'lib/vk_music/utility/last_profile_post_loader.rb', line 16

def self.call(agent, url: nil, owner_id: nil)
  path = url&.match(VK_PATH)&.captures&.first
  request = VkMusic::Request::Profile.new(profile_id: owner_id, profile_custom_path: path)
  request.call(agent)
  [request.id, request.last_post_id]
rescue Mechanize::ResponseCodeError
  [nil, nil]
end