Class: DTAS::CueIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/dtas/cue_index.rb

Overview

embedded CUE sheet representation for -player

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, offset) ⇒ CueIndex

Returns a new instance of CueIndex.



11
12
13
14
15
16
# File 'lib/dtas/cue_index.rb', line 11

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

#indexObject (readonly)

Returns the value of attribute index.



9
10
11
# File 'lib/dtas/cue_index.rb', line 9

def index
  @index
end

#offsetObject (readonly)

:nodoc:



8
9
10
# File 'lib/dtas/cue_index.rb', line 8

def offset
  @offset
end

Instance Method Details

#offset_samples(format) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/dtas/cue_index.rb', line 22

def offset_samples(format)
  case @offset
  when /\A(\d+)s\z/
    $1.to_i
  else
    format.hhmmss_to_samples(@offset)
  end
end

#pregap?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/dtas/cue_index.rb', line 31

def pregap?
  @index == 0
end

#subindex?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/dtas/cue_index.rb', line 39

def subindex?
  @index > 1
end

#to_hashObject



18
19
20
# File 'lib/dtas/cue_index.rb', line 18

def to_hash
  { "index" => @index, "offset" => @offset }
end

#track?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/dtas/cue_index.rb', line 35

def track?
  @index == 1
end