Class: AudioGlue::Snippet

Inherits:
Object
  • Object
show all
Defined in:
lib/audio_glue/snippet.rb

Overview

Represents an audio partial which will be used to build an output audio. There are a few types of snippets:

  • :file - represents audio file in local file system

  • :url - represents remote audio file

Other custom types can be created if custom adapter will support them.

adapters are responsible for processing every particular snippet type.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, source, snippet_packet, opts = {}) ⇒ Snippet

Returns a new instance of Snippet.

Parameters:

  • type (Symbol)

    :file, :url or anything else that can be handled by the adapter

  • source (String)

    Can be location, URL, or whatever depending on type

  • snippet_packet (AudioGlue::SnippetPacket)

    the snippet packet used to add the audio snippet to the packet when ‘-` unary method is called

  • opts (Hash) (defaults to: {})

    any specific options which are supported by adapter



20
21
22
23
24
25
# File 'lib/audio_glue/snippet.rb', line 20

def initialize(type, source, snippet_packet, opts = {})
  @type           = type
  @source         = source
  @snippet_packet = snippet_packet
  @opts           = opts
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



12
13
14
# File 'lib/audio_glue/snippet.rb', line 12

def opts
  @opts
end

#snippet_packetObject (readonly)

Returns the value of attribute snippet_packet.



12
13
14
# File 'lib/audio_glue/snippet.rb', line 12

def snippet_packet
  @snippet_packet
end

#sourceObject (readonly)

Returns the value of attribute source.



12
13
14
# File 'lib/audio_glue/snippet.rb', line 12

def source
  @source
end

#typeObject (readonly)

Returns the value of attribute type.



12
13
14
# File 'lib/audio_glue/snippet.rb', line 12

def type
  @type
end

Instance Method Details

#-@void

This method returns an undefined value.

Add self to the snippet packet. It’s used to support dash syntax in .glue files, like:

- file('/audio.mp3')


32
33
34
# File 'lib/audio_glue/snippet.rb', line 32

def -@
  @snippet_packet << self
end