Class: FastForward::Option

Inherits:
Object
  • Object
show all
Defined in:
lib/fastforward/option.rb

Instance Method Summary collapse

Constructor Details

#initialize(name, value, opts = {}) ⇒ Option

Returns a new instance of Option.



3
4
5
6
7
# File 'lib/fastforward/option.rb', line 3

def initialize(name, value, opts={})
  @name, @value, @opts = name, value, defaults.merge(opts)
  @stream_type  = nil
  @stream_index = nil
end

Instance Method Details

#defaultsObject



15
16
17
# File 'lib/fastforward/option.rb', line 15

def defaults
  { :stream_specifier_allowed => true }
end

#nameObject



19
20
21
# File 'lib/fastforward/option.rb', line 19

def name
  "-%s%s" % [ @name, stream_specifier ]
end

#stream(type, index = nil) ⇒ Object



9
10
11
12
13
# File 'lib/fastforward/option.rb', line 9

def stream(type, index=nil)
  @stream_type  = type
  @stream_index = index
  self # For chaining
end

#stream_specifierObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/fastforward/option.rb', line 27

def stream_specifier
  stream_type = case @stream_type
  when "audio" then ":a"
  when "video" then ":v"
  else
    ""
  end

  stream_type + ( @stream_index ? ":#{@stream_index}" : "" )
end

#to_sObject



38
39
40
# File 'lib/fastforward/option.rb', line 38

def to_s
  "%s %s" % [ name, value]
end

#valueObject



23
24
25
# File 'lib/fastforward/option.rb', line 23

def value
  @value
end