Class: Funky::URL
- Inherits:
-
Object
- Object
- Funky::URL
- Defined in:
- lib/funky/url.rb
Constant Summary collapse
- VIDEO_ID_REGEXES =
[/videos\/(\d+)(\/|)/i, /v=(\d*)/i, /\/v.\..*\/(\d*)\b/i]
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ URL
constructor
A new instance of URL.
- #video_id ⇒ Object
Constructor Details
#initialize(url) ⇒ URL
Returns a new instance of URL.
6 7 8 |
# File 'lib/funky/url.rb', line 6 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/funky/url.rb', line 3 def url @url end |
Instance Method Details
#video_id ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/funky/url.rb', line 10 def video_id return unless url.include? 'facebook.com' VIDEO_ID_REGEXES.each do |regex| url.match regex return $1 unless $1.nil? || $1.empty? || !$1.size.between?(15,17) end nil end |