Class: HBConfig

Inherits:
YAMLConfig show all
Defined in:
lib/hb-runner/hb_config.rb

Overview

This class processes a YAML file of Handbrake Options and can return it as a properly formatted string

Instance Attribute Summary collapse

Attributes inherited from YAMLConfig

#file

Instance Method Summary collapse

Methods inherited from YAMLConfig

#filename, #initialize

Constructor Details

This class inherits a constructor from YAMLConfig

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



5
6
7
# File 'lib/hb-runner/hb_config.rb', line 5

def options
  @options
end

Instance Method Details

#readObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hb-runner/hb_config.rb', line 7

def read
  @data ||= open(filename) { |f| YAML.load f }

  if @data['video'].keys.include?('x264opts')
    @data['video']['x264opts'] = @data['video']['x264opts'].map {|k,v| "#{k}=#{v}"}.join(':') 
  end

  loose_anamorphic = @data['video'].delete 'loose-anamorphic'
  @anamorphic_options = if loose_anamorphic and loose_anamorphic == true
    ' -loose-anamorphic'
  elsif loose_anamorphic
    " -loosePixelratio=#{ loose_anamorphic }"
  else
    ''
  end

  @options = @data
  self.to_s
end

#to_sObject



28
29
30
31
32
33
34
# File 'lib/hb-runner/hb_config.rb', line 28

def to_s
  @options.map do |o| 
    o.last.map do |k,v| 
      "--#{k} #{v.inspect}"
    end.join(' ')
  end.join(' ').gsub('true', '') + @anamorphic_options
end