Class: WebVideo::Adapters::AbstractAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/web_video/adapters/abstract_adapter.rb

Direct Known Subclasses

FfmpegAdapter

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @filepath = filepath
  
  @filename = File.basename(@filepath)
  @path = File.dirname(@filepath)
  
  @options = options.symbolize_keys
  @metadata = parse
end

Instance Attribute Details

#filenameObject

Returns the value of attribute filename.



4
5
6
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4

def filename
  @filename
end

#filepathObject

Returns the value of attribute filepath.



4
5
6
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4

def filepath
  @filepath
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/web_video/adapters/abstract_adapter.rb', line 4

def path
  @path
end

#video_streamsObject

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

#bitrateObject



28
29
30
# File 'lib/web_video/adapters/abstract_adapter.rb', line 28

def bitrate
  @metadata[:bitrate]
end

#command_nameObject



44
45
46
# File 'lib/web_video/adapters/abstract_adapter.rb', line 44

def command_name
  ''
end

#convert_commandObject



48
49
50
# File 'lib/web_video/adapters/abstract_adapter.rb', line 48

def convert_command
  []
end

#durationObject



24
25
26
# File 'lib/web_video/adapters/abstract_adapter.rb', line 24

def duration
  @metadata[:duration]
end

#file_exists?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/web_video/adapters/abstract_adapter.rb', line 16

def file_exists?
  File.exist?(@filepath)
end

#installed?Boolean

Returns:

  • (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, options = {})
  WebVideo::Tools.run_with_option(command_name, command, options)
end

#screenshot_commandObject



52
53
54
# File 'lib/web_video/adapters/abstract_adapter.rb', line 52

def screenshot_command
  []
end

#sizeObject



20
21
22
# File 'lib/web_video/adapters/abstract_adapter.rb', line 20

def size
  File.size(@filepath)
end

#streamsObject



32
33
34
# File 'lib/web_video/adapters/abstract_adapter.rb', line 32

def streams
  @metadata[:streams]
end

#video_streamObject



36
37
38
# File 'lib/web_video/adapters/abstract_adapter.rb', line 36

def video_stream
  video_streams.first
end