class SocialMediaUrlSplitter

Attributes

raw_url[R]

Public Class Methods

new(raw_url) click to toggle source
# File lib/buweb/services/social_media_url_splitter.rb, line 2
def initialize(raw_url)
  @raw_url = raw_url
end

Public Instance Methods

account() click to toggle source
# File lib/buweb/services/social_media_url_splitter.rb, line 12
def account
  # For vimeo: if the account is a group the group number will be the user, elsewise it will store the username.
  @account ||=
    if ((type == 'youtube' && path_parts[1] == 'user') || (type == 'vimeo' && path_parts[1] == 'groups'))
      path_parts[2]
    else
      path_parts[1]
    end
end
type() click to toggle source
# File lib/buweb/services/social_media_url_splitter.rb, line 8
def type
  @type ||= uri.host.to_s.split('.')[-2]
end

Private Instance Methods

path_parts() click to toggle source
# File lib/buweb/services/social_media_url_splitter.rb, line 28
def path_parts
  @path_parts ||= uri.path.split('/')
end
uri() click to toggle source
# File lib/buweb/services/social_media_url_splitter.rb, line 24
def uri
  @uri ||= URI.parse(URI.encode(raw_url))
end