Class: YoutubeUrlParser::YoutubeShareUrl

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/youtube_url_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

Returns the value of attribute link.



10
11
12
# File 'lib/youtube_url_parser.rb', line 10

def link
  @link
end

#uriObject

Returns the value of attribute uri.



10
11
12
# File 'lib/youtube_url_parser.rb', line 10

def uri
  @uri
end

Class Method Details

.share_link?(link) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/youtube_url_parser.rb', line 12

def self.share_link?(link)
  link.include?("/youtu.be")
end

Instance Method Details



23
24
25
# File 'lib/youtube_url_parser.rb', line 23

def parse_link
  self.uri = URI.parse(link)
end

#youtube_idObject



16
17
18
19
20
21
# File 'lib/youtube_url_parser.rb', line 16

def youtube_id
  parse_link
  return nil unless valid_host?

  uri.path.delete("/")
end