Class: VkMusic::WebParser::Profile

Inherits:
Base
  • Object
show all
Defined in:
lib/vk_music/web_parser/profile.rb

Overview

Profile page parser

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from VkMusic::WebParser::Base

Instance Method Details

#idObject

Profile id



20
21
22
23
24
25
# File 'lib/vk_music/web_parser/profile.rb', line 20

def id
  link = node.link_with(href: ID_CONTAINING_HREF, css: BASIS_LINK_SELECTOR)
  return unless link

  Integer(link.href.match(ID_CONTAINING_HREF).captures.first, 10)
end

#last_post_idObject

Last post ID



28
29
30
31
32
33
34
# File 'lib/vk_music/web_parser/profile.rb', line 28

def last_post_id
  ids = node.css('.wall_posts .wall_item').map do |el|
    str = el.at_css('.post__anchor')&.attr('name')&.match(POST_ANCHOR_NAME_REGEX)&.captures&.last
    str ? Integer(str, 10) : nil
  end
  ids.compact.max
end