Class: Voot::Cue

Inherits:
Object
  • Object
show all
Defined in:
lib/voot/cue.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Cue

Returns a new instance of Cue.



7
8
9
10
11
# File 'lib/voot/cue.rb', line 7

def initialize(options = {})
  @identifier = options[:identifier]
  @cue_timing = options.fetch(:cue_timing)
  @payload = options.fetch(:payload)
end

Instance Attribute Details

#cue_timingObject (readonly)

Returns the value of attribute cue_timing.



5
6
7
# File 'lib/voot/cue.rb', line 5

def cue_timing
  @cue_timing
end

#identifierObject (readonly)

Returns the value of attribute identifier.



5
6
7
# File 'lib/voot/cue.rb', line 5

def identifier
  @identifier
end

#payloadObject (readonly)

Returns the value of attribute payload.



5
6
7
# File 'lib/voot/cue.rb', line 5

def payload
  @payload
end

Instance Method Details

#has_identifier?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/voot/cue.rb', line 13

def has_identifier?
  !identifier.nil? && identifier.length > 0
end

#to_webvttObject



17
18
19
20
21
22
23
# File 'lib/voot/cue.rb', line 17

def to_webvtt
  if has_identifier?
    "#{identifier}\n#{cue_timing.to_webvtt}\n#{payload}"
  else
    "#{cue_timing.to_webvtt}\n#{payload}"
  end
end