Class: Decisive::RenderXLSContext

Inherits:
Struct
  • Object
show all
Defined in:
lib/decisive/render_xls_context.rb

Defined Under Namespace

Classes: Worksheet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RenderXLSContext

Returns a new instance of RenderXLSContext.



8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/decisive/render_xls_context.rb', line 8

def initialize *args
  super

  self.worksheets ||= []
  if worksheets.none?
    instance_eval &block

  else
    self.worksheets = worksheets.map do |name, records|
      Worksheet.new(records, name, block)
    end
  end
end

Instance Attribute Details

#blockObject

Returns the value of attribute block

Returns:

  • (Object)

    the current value of block



5
6
7
# File 'lib/decisive/render_xls_context.rb', line 5

def block
  @block
end

#filenameObject

Returns the value of attribute filename

Returns:

  • (Object)

    the current value of filename



5
6
7
# File 'lib/decisive/render_xls_context.rb', line 5

def filename
  @filename
end

#worksheetsObject

Returns the value of attribute worksheets

Returns:

  • (Object)

    the current value of worksheets



5
6
7
# File 'lib/decisive/render_xls_context.rb', line 5

def worksheets
  @worksheets
end

Instance Method Details

#csv?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/decisive/render_xls_context.rb', line 28

def csv?
  false
end

#to_xlsObject



22
23
24
25
26
# File 'lib/decisive/render_xls_context.rb', line 22

def to_xls
  workbook = RubyXL::Workbook.new
  workbook.worksheets.pop # rm default worsheet
  to_string(render(workbook))
end