Class: Buttons::Javascript::JsGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/buttons/javascript/js_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(button) ⇒ JsGenerator

Returns a new instance of JsGenerator.



6
7
8
9
# File 'lib/buttons/javascript/js_generator.rb', line 6

def initialize(button)
  @button = button
  # @compressor = YUI::JavaScriptCompressor.new
end

Instance Method Details

#to_jsObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/buttons/javascript/js_generator.rb', line 11

def to_js
  js = %Q[
    (function () {
      this.#{@button.namespace.capitalize} = {};

      #{@button.js_functions.map { |function| 
        function.to_js(@button.namespace.capitalize)
      }.join("\n")}
    })();
  ]
  
  # @compressor.compress(js)
  js.strip_whitespace
end