Class: Flatbed::Clip
- Inherits:
-
Object
- Object
- Flatbed::Clip
- Defined in:
- lib/flatbed/clip.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#clip ⇒ Object
Returns the value of attribute clip.
-
#clip_name ⇒ Object
Returns the value of attribute clip_name.
-
#source ⇒ Object
Returns the value of attribute source.
-
#source_name ⇒ Object
Returns the value of attribute source_name.
Instance Method Summary collapse
- #command ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #exists? ⇒ Boolean
-
#initialize(clip, convert_from = nil) ⇒ Clip
constructor
A new instance of Clip.
- #input_options(opts = {}) ⇒ Object
- #input_options=(opts) ⇒ Object
- #options ⇒ Object
- #output_options(opts = {}) ⇒ Object
- #output_options=(opts) ⇒ Object
- #set_clip(path) ⇒ Object
- #set_source(path) ⇒ Object
- #source_exists? ⇒ Boolean
Constructor Details
#initialize(clip, convert_from = nil) ⇒ Clip
Returns a new instance of Clip.
8 9 10 11 |
# File 'lib/flatbed/clip.rb', line 8 def initialize(clip, convert_from = nil) set_source convert_from if convert_from set_clip clip end |
Instance Attribute Details
#clip ⇒ Object
Returns the value of attribute clip.
6 7 8 |
# File 'lib/flatbed/clip.rb', line 6 def clip @clip end |
#clip_name ⇒ Object
Returns the value of attribute clip_name.
6 7 8 |
# File 'lib/flatbed/clip.rb', line 6 def clip_name @clip_name end |
#source ⇒ Object
Returns the value of attribute source.
6 7 8 |
# File 'lib/flatbed/clip.rb', line 6 def source @source end |
#source_name ⇒ Object
Returns the value of attribute source_name.
6 7 8 |
# File 'lib/flatbed/clip.rb', line 6 def source_name @source_name end |
Instance Method Details
#command ⇒ Object
13 14 15 16 |
# File 'lib/flatbed/clip.rb', line 13 def command raise "No input file specified." if self.source.to_s.empty? "ffmpeg #{format_options input_options}-i #{source} #{format_options output_options}#{clip}" end |
#create ⇒ Object
18 19 20 |
# File 'lib/flatbed/clip.rb', line 18 def create `#{command}` end |
#destroy ⇒ Object
22 23 24 |
# File 'lib/flatbed/clip.rb', line 22 def destroy FileUtils.rm clip end |
#exists? ⇒ Boolean
26 27 28 |
# File 'lib/flatbed/clip.rb', line 26 def exists? File.exists? clip end |
#input_options(opts = {}) ⇒ Object
37 38 39 40 |
# File 'lib/flatbed/clip.rb', line 37 def opts = {} [:input] ||= {} [:input].merge!(opts) end |
#input_options=(opts) ⇒ Object
42 43 44 |
# File 'lib/flatbed/clip.rb', line 42 def opts [:input] = opts end |
#options ⇒ Object
30 31 32 33 34 35 |
# File 'lib/flatbed/clip.rb', line 30 def ||= { :input => {}, :output => {} } end |
#output_options(opts = {}) ⇒ Object
46 47 48 49 |
# File 'lib/flatbed/clip.rb', line 46 def opts = {} [:output] ||= {} [:output].merge!(opts) end |
#output_options=(opts) ⇒ Object
51 52 53 |
# File 'lib/flatbed/clip.rb', line 51 def opts [:output] = opts end |
#set_clip(path) ⇒ Object
55 56 57 58 |
# File 'lib/flatbed/clip.rb', line 55 def set_clip(path) self.clip = File.(path) self.clip_name = clip.split("/").last end |
#set_source(path) ⇒ Object
60 61 62 63 |
# File 'lib/flatbed/clip.rb', line 60 def set_source(path) self.source = File.(path) self.source_name = source.split("/").last end |
#source_exists? ⇒ Boolean
65 66 67 |
# File 'lib/flatbed/clip.rb', line 65 def source_exists? File.exists? source end |