Class: HandBrake::Disc
- Inherits:
-
Object
- Object
- HandBrake::Disc
- Defined in:
- lib/handbrake/disc.rb
Overview
An object representation of the output from HandBrakeCLI's
--scan
mode.
Instance Attribute Summary collapse
-
#name ⇒ String
The name of the disc.
-
#raw_output ⇒ String?
The HandBrakeCLI scan output from which this instance was parsed, if available.
-
#raw_tree ⇒ String?
readonly
A tree representing the indented output at the end of the HandBrakeCLI scan output, if available.
-
#titles ⇒ Hash<Fixnum, Title>
readonly
The titles in the disc.
Class Method Summary collapse
-
.from_output(output) ⇒ Disc
Builds a new Disc instance from the output of
HandBrakeCLI --scan
.
Instance Method Summary collapse
-
#initialize(name = nil) ⇒ Disc
constructor
A new instance of Disc.
- #to_yaml_properties ⇒ Object
Constructor Details
#initialize(name = nil) ⇒ Disc
Returns a new instance of Disc.
39 40 41 42 |
# File 'lib/handbrake/disc.rb', line 39 def initialize(name=nil) @name = name @titles = {} end |
Instance Attribute Details
#name ⇒ String
The name of the disc.
37 38 39 |
# File 'lib/handbrake/disc.rb', line 37 def name @name end |
#raw_output ⇒ String?
The HandBrakeCLI scan output from which this instance was parsed, if available.
18 19 20 |
# File 'lib/handbrake/disc.rb', line 18 def raw_output @raw_output end |
#raw_tree ⇒ String? (readonly)
A tree representing the indented output at the end of the HandBrakeCLI scan output, if available.
25 26 27 |
# File 'lib/handbrake/disc.rb', line 25 def raw_tree @raw_tree end |
#titles ⇒ Hash<Fixnum, Title> (readonly)
The titles in the disc. The keys are the title numbers.
31 32 33 |
# File 'lib/handbrake/disc.rb', line 31 def titles @titles end |
Class Method Details
.from_output(output) ⇒ Disc
Builds a new HandBrake::Disc instance from the output of HandBrakeCLI
--scan
.
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/handbrake/disc.rb', line 50 def self.from_output(output) name = File.basename( output.split("\n").grep(/hb_scan/).first.scan(/path=([^,]*),/).first.first) self.new(name).tap do |disc| disc.raw_output = output disc.raw_tree.children. collect { |title_node| Title.from_tree(title_node) }. each { |title| title.disc = disc }. each { |title| disc.titles[title.number] = title } end end |
Instance Method Details
#to_yaml_properties ⇒ Object
75 76 77 |
# File 'lib/handbrake/disc.rb', line 75 def to_yaml_properties %w(@name @titles) end |