Class: HandBrake::Title
- Inherits:
-
Object
- Object
- HandBrake::Title
- Includes:
- DurationAsSeconds
- Defined in:
- lib/handbrake/titles.rb
Overview
Metadata about a single DVD title.
Instance Attribute Summary collapse
-
#chapters ⇒ Hash<Fixnum,Chapter>
The chapters into which the title is divided, indexed by chapter number (a positive integer).
-
#collection ⇒ Titles
The collection this title belongs to.
-
#duration ⇒ String
The duration of the title in the format "hh:mm:ss".
-
#main_feature ⇒ Boolean
writeonly
Whether HandBrake considers this title the "main feature".
-
#number ⇒ Fixnum
The title number of this title (a positive integer).
Class Method Summary collapse
-
.from_tree(title_node) ⇒ Title
Creates a new instance from the given scan subtree.
Instance Method Summary collapse
-
#all_chapters ⇒ Array<Chapter>
The chapters of the title, sorted by chapter number.
-
#main_feature? ⇒ Boolean
Whether HandBrake considers this title the "main feature".
Methods included from DurationAsSeconds
Instance Attribute Details
#chapters ⇒ Hash<Fixnum,Chapter>
Returns The chapters into which the title is divided, indexed by chapter number (a positive integer).
163 164 165 |
# File 'lib/handbrake/titles.rb', line 163 def chapters @chapters ||= {} end |
#collection ⇒ Titles
Returns The collection this title belongs to.
129 130 131 |
# File 'lib/handbrake/titles.rb', line 129 def collection @collection end |
#duration ⇒ String
Returns The duration of the title in the format "hh:mm:ss".
115 116 117 |
# File 'lib/handbrake/titles.rb', line 115 def duration @duration end |
#main_feature=(value) ⇒ Boolean (writeonly)
Returns Whether HandBrake considers this title the "main feature".
125 126 127 |
# File 'lib/handbrake/titles.rb', line 125 def main_feature=(value) @main_feature = value end |
#number ⇒ Fixnum
Returns The title number of this title (a positive integer).
110 111 112 |
# File 'lib/handbrake/titles.rb', line 110 def number @number end |
Class Method Details
.from_tree(title_node) ⇒ Title
Creates a new instance from the given scan subtree.
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/handbrake/titles.rb', line 137 def self.from_tree(title_node) self.new.tap do |title| title.number = title_node.name.scan(/title (\d+)/).first.first.to_i title.duration = title_node.children. detect { |c| c.name =~ /duration/ }.name. scan(/duration: (\d\d:\d\d:\d\d)/).first.first title.chapters = title_node['chapters:'].children. collect { |ch_node| Chapter.from_tree(ch_node) }. tap { |chapters| chapters.each { |c| c.title = title } }. inject({}) { |h, ch| h[ch.number] = ch; h } # !! is so that there's no reference to the node in the # resulting object title.main_feature = !!title_node.children.detect { |c| c.name =~ /Main Feature/ } end end |
Instance Method Details
#all_chapters ⇒ Array<Chapter>
Returns The chapters of the title, sorted by chapter number.
170 171 172 |
# File 'lib/handbrake/titles.rb', line 170 def all_chapters chapters.keys.sort.collect { |k| chapters[k] } end |
#main_feature? ⇒ Boolean
Returns Whether HandBrake considers this title the "main feature".
156 157 158 |
# File 'lib/handbrake/titles.rb', line 156 def main_feature? @main_feature end |