class Flowplayer::Player
Attributes
dom_id[RW]
functions[RW]
options[RW]
swf[RW]
Public Class Methods
new(dom_id, swf, lib='jquery', &block)
click to toggle source
# File lib/flowplayer/player.rb, line 6 def initialize(dom_id, swf, lib='jquery', &block) @dom_id, @swf, @lib = dom_id, swf, lib @options = {} @functions = {} block.call(self) self end
Public Instance Methods
jquery(func)
click to toggle source
# File lib/flowplayer/player.rb, line 40 def jquery(func) <<-EOS $(document).ready(function() { #{func} }); EOS end
library(func)
click to toggle source
# File lib/flowplayer/player.rb, line 31 def library(func) case @lib when 'jquery' jquery(func) when 'prototype' prototype(func) end end
prototype(func)
click to toggle source
# File lib/flowplayer/player.rb, line 48 def prototype(func) <<-EOS document.observe("dom:loaded", function() { #{func} }); EOS end
to_js()
click to toggle source
# File lib/flowplayer/player.rb, line 14 def to_js json = options_to_javascript json += functions_to_javascript "{#{json.join(', ')}}" end
Private Instance Methods
functions_to_javascript()
click to toggle source
# File lib/flowplayer/player.rb, line 77 def functions_to_javascript functions.map {|option, function| "\"#{option}\":#{function}"} end
method_missing(method, *args, &block)
click to toggle source
# File lib/flowplayer/player.rb, line 87 def method_missing(method, *args, &block) raise "Setters are not supported use method('whatever') to set configs" if /\=$/.match(method.to_s) if block.nil? options[method] = args.first else params = block.parameters.collect {|param| param[1]} functions[method] = "function(#{params.join(", ")}) { #{block.call.gsub(/\;$/, '')}; }" end return method end
options_to_javascript()
click to toggle source
# File lib/flowplayer/player.rb, line 81 def options_to_javascript options.map do |option, value| "\"#{option}\":#{value.to_json}" end end