Class: Flatbed::Clip

Inherits:
Object
  • Object
show all
Defined in:
lib/flatbed/clip.rb

Direct Known Subclasses

StillClip

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#clipObject

Returns the value of attribute clip.



6
7
8
# File 'lib/flatbed/clip.rb', line 6

def clip
  @clip
end

#clip_nameObject

Returns the value of attribute clip_name.



6
7
8
# File 'lib/flatbed/clip.rb', line 6

def clip_name
  @clip_name
end

#sourceObject

Returns the value of attribute source.



6
7
8
# File 'lib/flatbed/clip.rb', line 6

def source
  @source
end

#source_nameObject

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

#commandObject



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

#createObject



18
19
20
# File 'lib/flatbed/clip.rb', line 18

def create
  `#{command}`
end

#destroyObject



22
23
24
# File 'lib/flatbed/clip.rb', line 22

def destroy
  FileUtils.rm clip
end

#exists?Boolean

Returns:

  • (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 input_options opts = {}
  options[:input] ||= {}
  options[:input].merge!(opts)
end

#input_options=(opts) ⇒ Object



42
43
44
# File 'lib/flatbed/clip.rb', line 42

def input_options= opts
  options[:input] = opts
end

#optionsObject



30
31
32
33
34
35
# File 'lib/flatbed/clip.rb', line 30

def options
  @options ||= {
    :input => {},
    :output => {}
  }
end

#output_options(opts = {}) ⇒ Object



46
47
48
49
# File 'lib/flatbed/clip.rb', line 46

def output_options opts = {}
  options[:output] ||= {}
  options[:output].merge!(opts)
end

#output_options=(opts) ⇒ Object



51
52
53
# File 'lib/flatbed/clip.rb', line 51

def output_options= opts
  options[: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.expand_path(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.expand_path(path)
  self.source_name = source.split("/").last
end

#source_exists?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/flatbed/clip.rb', line 65

def source_exists?
  File.exists? source
end