Class: HandBrake::Title
- Inherits:
-
Object
- Object
- HandBrake::Title
- Includes:
- ConstructWithProperties, DurationAsSeconds
- Defined in:
- lib/handbrake/disc.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).
-
#disc ⇒ Disc
The disc 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 ConstructWithProperties
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).
202 203 204 |
# File 'lib/handbrake/disc.rb', line 202 def chapters @chapters ||= {} end |
#disc ⇒ Disc
Returns The disc this title belongs to.
168 169 170 |
# File 'lib/handbrake/disc.rb', line 168 def disc @disc end |
#duration ⇒ String
Returns The duration of the title in the format "hh:mm:ss".
154 155 156 |
# File 'lib/handbrake/disc.rb', line 154 def duration @duration end |
#main_feature=(value) ⇒ Boolean (writeonly)
Returns Whether HandBrake considers this title the "main feature".
164 165 166 |
# File 'lib/handbrake/disc.rb', line 164 def main_feature=(value) @main_feature = value end |
#number ⇒ Fixnum
Returns The title number of this title (a positive integer).
149 150 151 |
# File 'lib/handbrake/disc.rb', line 149 def number @number end |
Class Method Details
.from_tree(title_node) ⇒ Title
Creates a new instance from the given scan subtree.
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/handbrake/disc.rb', line 176 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.
209 210 211 |
# File 'lib/handbrake/disc.rb', line 209 def all_chapters chapters.keys.sort.collect { |k| chapters[k] } end |
#main_feature? ⇒ Boolean
Returns Whether HandBrake considers this title the "main feature".
195 196 197 |
# File 'lib/handbrake/disc.rb', line 195 def main_feature? @main_feature end |