Class: Rspreadsheet::Worksheet
- Inherits:
-
Object
- Object
- Rspreadsheet::Worksheet
show all
- Extended by:
- Forwardable
- Defined in:
- lib/rspreadsheet/worksheet.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(source_node = nil) ⇒ Worksheet
Returns a new instance of Worksheet.
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/rspreadsheet/worksheet.rb', line 32
def initialize(source_node=nil)
@source_node = source_node
@worksheetcells=WorksheetCells.new
rowi = 0
unless @source_node.nil?
@source_node.elements.select{ |node| node.name == 'table-row'}.each do |row_source_node|
coli = 0
row_source_node.elements.select{ |node| node.name == 'table-cell'}.each do |cell_source_node|
cells.initialize_cell(rowi,coli,cell_source_node)
coli += 1
end
rowi += 1
end
end
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/rspreadsheet/worksheet.rb', line 59
def method_missing method_name, *args, &block
if method_name.to_s.match(/^([A-Z]{1,3})(\d{1,8})(=?)$/)
row,col = Tools.convert_cell_address($~[1],$~[2])
assignchar = $~[3]
if assignchar == '='
self.cells[row,col].value = args.first
else
self.cells[row,col].value
end
else
super
end
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
28
29
30
|
# File 'lib/rspreadsheet/worksheet.rb', line 28
def name
@name
end
|
Instance Method Details
#[](r, c) ⇒ Object
50
51
52
|
# File 'lib/rspreadsheet/worksheet.rb', line 50
def [](r,c)
cells[r,c].value
end
|
#[]=(r, c, avalue) ⇒ Object
53
54
55
|
# File 'lib/rspreadsheet/worksheet.rb', line 53
def []=(r,c,avalue)
cells[r,c].value=avalue
end
|
#cells ⇒ Object
47
48
49
|
# File 'lib/rspreadsheet/worksheet.rb', line 47
def cells
@worksheetcells
end
|
#rows ⇒ Object
56
57
58
|
# File 'lib/rspreadsheet/worksheet.rb', line 56
def rows
WorksheetRows.new(self)
end
|