Class: LinkThumbnailer::VideoParser
- Inherits:
-
Object
- Object
- LinkThumbnailer::VideoParser
- Defined in:
- lib/link_thumbnailer/video_parser.rb
Instance Attribute Summary collapse
-
#parser ⇒ Object
readonly
Returns the value of attribute parser.
Instance Method Summary collapse
- #duration ⇒ Object
- #embed_code ⇒ Object
- #id ⇒ Object
-
#initialize(video) ⇒ VideoParser
constructor
A new instance of VideoParser.
- #provider ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(video) ⇒ VideoParser
Returns a new instance of VideoParser.
8 9 10 11 12 |
# File 'lib/link_thumbnailer/video_parser.rb', line 8 def initialize(video) @parser = ::VideoInfo.new(video.src.to_s) rescue ::VideoInfo::UrlError @parser = nil end |
Instance Attribute Details
#parser ⇒ Object (readonly)
Returns the value of attribute parser.
6 7 8 |
# File 'lib/link_thumbnailer/video_parser.rb', line 6 def parser @parser end |
Instance Method Details
#duration ⇒ Object
26 27 28 29 30 |
# File 'lib/link_thumbnailer/video_parser.rb', line 26 def duration parser.duration rescue NoMethodError, ::OpenURI::HTTPError nil end |
#embed_code ⇒ Object
38 39 40 41 42 |
# File 'lib/link_thumbnailer/video_parser.rb', line 38 def parser. rescue NoMethodError, ::OpenURI::HTTPError nil end |
#id ⇒ Object
14 15 16 17 18 |
# File 'lib/link_thumbnailer/video_parser.rb', line 14 def id parser.video_id rescue NoMethodError nil end |
#provider ⇒ Object
32 33 34 35 36 |
# File 'lib/link_thumbnailer/video_parser.rb', line 32 def provider parser.provider rescue NoMethodError, ::OpenURI::HTTPError nil end |
#size ⇒ Object
20 21 22 23 24 |
# File 'lib/link_thumbnailer/video_parser.rb', line 20 def size [parser.width, parser.height] rescue NoMethodError, ::OpenURI::HTTPError [] end |