Sha256: 05517508437ddd9263cad334a64e0124f85b15326adce0e2480a707faab02ce4

Contents?: true

Size: 951 Bytes

Versions: 10

Compression:

Stored size: 951 Bytes

Contents

require 'writeexcel'
require 'stringio'

module Ruby2xlsx
  class Base
    # Constructs a new ejs engine based on given xlsx", :root => true, :view_path => "/path/to/views" })
    #
    def initialize(source, options = {})
      @source = source
      @options = options
      @compiled = false
      @io = ::StringIO.new
    end
    
    def workbook
      @workbook ||= ::WriteExcel.new(@io)
    end
    
    def worksheet
      @worksheet ||= add_worksheet(worksheet_name)
    end
    
    def add_worksheet(*args)
      @worksheet = workbook.add_worksheet(*args)
    end
    
    def render(*args)
      workbook.close
      @io.string
    end
    
    def worksheet_name
      "somename"
    end
    
    def method_missing(m, *args, &block)
      if worksheet.respond_to?(m)
        worksheet.send(m, *args, &block)
      elsif workbook.respond_to?(m)
        workbook.send(m, *args, &block)
      else
        super
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
ruby2xlsx-0.0.4 lib/ruby2xlsx/base.rb
ruby2xlsx-0.0.3 lib/ruby2xlsx/base.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/ruby2xlsx-0.0.2/lib/ruby2xlsx/base.rb
sunrise-cms-0.3.3 vendor/bundle/ruby/1.9.1/gems/ruby2xlsx-0.0.2/lib/ruby2xlsx/base.rb
sunrise-cms-0.3.2 vendor/bundle/ruby/1.9.1/gems/ruby2xlsx-0.0.2/lib/ruby2xlsx/base.rb
sunrise-cms-0.3.1 vendor/bundle/ruby/1.9.1/gems/ruby2xlsx-0.0.2/lib/ruby2xlsx/base.rb
sunrise-cms-0.3.0 vendor/bundle/ruby/1.9.1/gems/ruby2xlsx-0.0.2/lib/ruby2xlsx/base.rb
sunrise-cms-0.3.0.rc vendor/bundle/ruby/1.9.1/gems/ruby2xlsx-0.0.2/lib/ruby2xlsx/base.rb
ruby2xlsx-0.0.2 lib/ruby2xlsx/base.rb
ruby2xlsx-0.0.1 lib/ruby2xlsx/base.rb