Sha256: 5b94c7ca82f6365a34e5fd2c65f1417c438c1cc106ea545c386dc34cd04d90f1

Contents?: true

Size: 708 Bytes

Versions: 1

Compression:

Stored size: 708 Bytes

Contents

module DashcodeConverter
  
  class Controller

    DECL_TEMPLATE= <<-EOF
        /*import coherent*/

        <%=namespace%>.<%=name%>= Class.create(coherent.ViewController, {
        
        <%=@methods.join(",\n").indent(INDENT)%>
        
        });
    EOF
    
    attr_reader :name, :namespace
    
    def initialize(name, namespace=nil)
      @name= "#{name.capitalize}Controller"
      @namespace= namespace || name
      @methods= []
    end
    
    def add_action_method(name)
      @methods << "#{name}: function(sender)\n{\n}"
    end

    def declaration
      return @declaration if @declaration
      @declaration= ERB.new(DECL_TEMPLATE.remove_indent).result binding
    end
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dashcode-converter-0.0.1 lib/dashcode-converter/controller.rb