Class: ExcelWalker::Writer::Cells

Inherits:
Object
  • Object
show all
Defined in:
lib/excel_walker/writer/cells.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(default_style) ⇒ Cells

Returns a new instance of Cells.



7
8
9
10
# File 'lib/excel_walker/writer/cells.rb', line 7

def initialize(default_style)
  @default_style = default_style
  @data, @styles, @width = [], [], 0
end

Instance Attribute Details

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/excel_walker/writer/cells.rb', line 5

def data
  @data
end

#default_styleObject

Returns the value of attribute default_style.



5
6
7
# File 'lib/excel_walker/writer/cells.rb', line 5

def default_style
  @default_style
end

#stylesObject

Returns the value of attribute styles.



5
6
7
# File 'lib/excel_walker/writer/cells.rb', line 5

def styles
  @styles
end

#widthObject

Returns the value of attribute width.



5
6
7
# File 'lib/excel_walker/writer/cells.rb', line 5

def width
  @width
end

Instance Method Details

#buildObject



26
27
28
29
# File 'lib/excel_walker/writer/cells.rb', line 26

def build
  build_data
  build_styles
end

#set_data_at(range, cell_data) ⇒ Object



12
13
14
15
16
17
# File 'lib/excel_walker/writer/cells.rb', line 12

def set_data_at(range, cell_data)
  range = [range] if range.is_a?(Fixnum)
  range.each do |i|
    data[i] = cell_data
  end
end

#set_style_at(range, cell_style) ⇒ Object



19
20
21
22
23
24
# File 'lib/excel_walker/writer/cells.rb', line 19

def set_style_at(range, cell_style)
  range = [range] if range.is_a?(Fixnum)
  range.each do |i|
    styles[i] = cell_style
  end
end