Class: DTAS::CueIndex
- Inherits:
-
Object
- Object
- DTAS::CueIndex
- Defined in:
- lib/dtas/cue_index.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
readonly
Returns the value of attribute index.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
-
#initialize(index, offset) ⇒ CueIndex
constructor
A new instance of CueIndex.
- #offset_samples(format) ⇒ Object
- #pregap? ⇒ Boolean
- #subindex? ⇒ Boolean
- #to_hash ⇒ Object
- #track? ⇒ Boolean
Constructor Details
#initialize(index, offset) ⇒ CueIndex
Returns a new instance of CueIndex.
8 9 10 11 12 13 |
# File 'lib/dtas/cue_index.rb', line 8 def initialize(index, offset) @index = index.to_i # must be compatible with the sox "trim" effect @offset = offset # "#{INTEGER}s" (samples) or HH:MM:SS:FRAC end |
Instance Attribute Details
#index ⇒ Object (readonly)
Returns the value of attribute index.
6 7 8 |
# File 'lib/dtas/cue_index.rb', line 6 def index @index end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/dtas/cue_index.rb', line 5 def offset @offset end |
Instance Method Details
#offset_samples(format) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/dtas/cue_index.rb', line 19 def offset_samples(format) case @offset when /\A(\d+)s\z/ $1.to_i else format.hhmmss_to_samples(@offset) end end |
#pregap? ⇒ Boolean
28 29 30 |
# File 'lib/dtas/cue_index.rb', line 28 def pregap? @index == 0 end |
#subindex? ⇒ Boolean
36 37 38 |
# File 'lib/dtas/cue_index.rb', line 36 def subindex? @index > 1 end |
#to_hash ⇒ Object
15 16 17 |
# File 'lib/dtas/cue_index.rb', line 15 def to_hash { "index" => @index, "offset" => @offset } end |
#track? ⇒ Boolean
32 33 34 |
# File 'lib/dtas/cue_index.rb', line 32 def track? @index == 1 end |