Class: HandBrake::Titles

Inherits:
Hash
  • Object
show all
Defined in:
lib/handbrake/titles.rb

Overview

And enhanced Hash which can self-parse the output from HandBrakeCLI's --scan mode. The keys of this hash will be title numbers and the values will be Title instances.

See Also:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#raw_outputString?

The HandBrakeCLI scan output from which this instance was parsed, if available.

Returns:

  • (String, nil)


19
20
21
# File 'lib/handbrake/titles.rb', line 19

def raw_output
  @raw_output
end

#raw_treeString? (readonly)

A tree representing the indented output at the end of the HandBrakeCLI scan output, if available.

Returns:

  • (String, nil)


26
27
28
# File 'lib/handbrake/titles.rb', line 26

def raw_tree
  @raw_tree
end

Class Method Details

.from_output(output) ⇒ Titles

Builds a new HandBrake::Titles instance from the output of HandBrakeCLI --scan.

Parameters:

  • output (String)

    the raw contents from the scan

Returns:

  • (Titles)

    a new, completely initialized title catalog



34
35
36
37
38
39
40
41
42
# File 'lib/handbrake/titles.rb', line 34

def self.from_output(output)
  self.new.tap do |titles|
    titles.raw_output = output
    titles.raw_tree.children.
      collect { |title_node| Title.from_tree(title_node) }.
      each { |title| title.collection = titles }.
      each { |title| titles[title.number] = title }
  end
end