Class: WebVideo::Adapters::AbstractAdapter
- Inherits:
-
Object
- Object
- WebVideo::Adapters::AbstractAdapter
- Defined in:
- lib/web_video/adapters/abstract_adapter.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#path ⇒ Object
Returns the value of attribute path.
-
#video_streams ⇒ Object
Returns the value of attribute video_streams.
Instance Method Summary collapse
- #bitrate ⇒ Object
- #command_name ⇒ Object
- #convert_command ⇒ Object
- #duration ⇒ Object
- #file_exists? ⇒ Boolean
-
#initialize(filepath, options = {}) ⇒ AbstractAdapter
constructor
A new instance of AbstractAdapter.
- #installed? ⇒ Boolean
- #run(command, options = {}) ⇒ Object
- #screenshot_command ⇒ Object
- #size ⇒ Object
- #streams ⇒ Object
- #video_stream ⇒ Object
Constructor Details
#initialize(filepath, options = {}) ⇒ AbstractAdapter
Returns a new instance of AbstractAdapter.
6 7 8 9 10 11 12 13 14 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 6 def initialize(filepath, = {}) @filepath = filepath @filename = File.basename(@filepath) @path = File.dirname(@filepath) @options = .symbolize_keys @metadata = parse end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
4 5 6 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4 def filename @filename end |
#filepath ⇒ Object
Returns the value of attribute filepath.
4 5 6 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4 def filepath @filepath end |
#path ⇒ Object
Returns the value of attribute path.
4 5 6 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4 def path @path end |
#video_streams ⇒ Object
Returns the value of attribute video_streams.
4 5 6 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4 def video_streams @video_streams end |
Instance Method Details
#bitrate ⇒ Object
28 29 30 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 28 def bitrate @metadata[:bitrate] end |
#command_name ⇒ Object
44 45 46 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 44 def command_name '' end |
#convert_command ⇒ Object
48 49 50 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 48 def convert_command [] end |
#duration ⇒ Object
24 25 26 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 24 def duration @metadata[:duration] end |
#file_exists? ⇒ Boolean
16 17 18 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 16 def file_exists? File.exist?(@filepath) end |
#installed? ⇒ Boolean
56 57 58 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 56 def installed? !WebVideo::Tools.run("which", command_name).blank? end |
#run(command, options = {}) ⇒ Object
60 61 62 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 60 def run(command, = {}) WebVideo::Tools.run_with_option(command_name, command, ) end |
#screenshot_command ⇒ Object
52 53 54 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 52 def screenshot_command [] end |
#size ⇒ Object
20 21 22 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 20 def size File.size(@filepath) end |
#streams ⇒ Object
32 33 34 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 32 def streams @metadata[:streams] end |
#video_stream ⇒ Object
36 37 38 |
# File 'lib/web_video/adapters/abstract_adapter.rb', line 36 def video_stream video_streams.first end |