class ActiveVlc::Stage::Base

Attributes

options[R]

Options represents vlc's sout options

type[R]

Public Class Methods

new(type = :dummy, opts = {}) click to toggle source
Calls superclass method ActiveVlc::Parametric::new
# File lib/activevlc/stage/base.rb, line 23
def initialize(type = :dummy, opts = {})
  super() # ActiveVlc::Parametric
  @options = Hash.new.merge opts
  @type = type
end

Public Instance Methods

[](key) click to toggle source
# File lib/activevlc/stage/base.rb, line 29
def [](key) @options[key] end
[]=(key, value) click to toggle source
# File lib/activevlc/stage/base.rb, line 30
def []=(key, value) @options[key] = value end
fragment() click to toggle source
# File lib/activevlc/stage/base.rb, line 32
def fragment
  render_fragment(@type, @options)
end

Protected Instance Methods

format_value(value) click to toggle source
# File lib/activevlc/stage/base.rb, line 59
def format_value(value)
  if value.is_a? Base
    "#{value.fragment}"
  elsif value.is_a? String
    "'#{value}'"
  else
    "#{value}"
  end
end
render_fragment(k, h) click to toggle source

Handles the rendering of the options hash to a vlc sout format

# File lib/activevlc/stage/base.rb, line 39
def render_fragment(k, h)
  map = h.map do |key, value|
    if value.nil?
      "#{key}"
    elsif value == false
      "no-#{key}"
    elsif value.is_a?(Base) and not value.type
      "#{key}#{format_value value}"
    else
      "#{key}=#{format_value value}"
    end
  end.join(', ')

  if map == ""
    "#{k}"
  else
    "#{k}{#{map}}"
  end
end