Class: Spreadshoot::Table
- Inherits:
-
Object
- Object
- Spreadshoot::Table
- Defined in:
- lib/spreadshoot.rb
Overview
Allows you to group cells to a logical table within a worksheet. Makes putting several tables to the same worksheet easier.
Instance Attribute Summary collapse
-
#col_index ⇒ Object
Returns the value of attribute col_index.
-
#col_max ⇒ Object
readonly
Returns the value of attribute col_max.
-
#col_topleft ⇒ Object
readonly
Returns the value of attribute col_topleft.
-
#direction ⇒ Object
readonly
Returns the value of attribute direction.
-
#row_index ⇒ Object
Returns the value of attribute row_index.
-
#row_max ⇒ Object
readonly
Returns the value of attribute row_max.
-
#row_topleft ⇒ Object
readonly
Returns the value of attribute row_topleft.
-
#worksheet ⇒ Object
readonly
Returns the value of attribute worksheet.
Instance Method Summary collapse
-
#coords ⇒ Object
alphanumeric representation of coordinates.
- #current_col ⇒ Object
- #current_row ⇒ Object
-
#initialize(worksheet, options = {}) ⇒ Table
constructor
A new instance of Table.
- #row(options = {}) {|row| ... } ⇒ Object
Constructor Details
#initialize(worksheet, options = {}) ⇒ Table
Returns a new instance of Table.
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
# File 'lib/spreadshoot.rb', line 427 def initialize worksheet, = {} @worksheet = worksheet @options = @direction = [:direction] || :vertical @row_index = 0 @col_index = 0 @row_max = 0 @col_max = 0 @row_topleft = [:row_topleft] || @worksheet.row_index @col_topleft = [:col_topleft] || @worksheet.col_index if tbl = [:next_to] @row_topleft = tbl.row_topleft @col_topleft = tbl.col_topleft + tbl.col_max end end |
Instance Attribute Details
#col_index ⇒ Object
Returns the value of attribute col_index.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def col_index @col_index end |
#col_max ⇒ Object (readonly)
Returns the value of attribute col_max.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def col_max @col_max end |
#col_topleft ⇒ Object (readonly)
Returns the value of attribute col_topleft.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def col_topleft @col_topleft end |
#direction ⇒ Object (readonly)
Returns the value of attribute direction.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def direction @direction end |
#row_index ⇒ Object
Returns the value of attribute row_index.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def row_index @row_index end |
#row_max ⇒ Object (readonly)
Returns the value of attribute row_max.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def row_max @row_max end |
#row_topleft ⇒ Object (readonly)
Returns the value of attribute row_topleft.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def row_topleft @row_topleft end |
#worksheet ⇒ Object (readonly)
Returns the value of attribute worksheet.
423 424 425 |
# File 'lib/spreadshoot.rb', line 423 def worksheet @worksheet end |
Instance Method Details
#coords ⇒ Object
alphanumeric representation of coordinates
477 478 479 |
# File 'lib/spreadshoot.rb', line 477 def coords "#{Cell.alpha_index(current_col)}#{current_row+1}" end |
#current_col ⇒ Object
472 473 474 |
# File 'lib/spreadshoot.rb', line 472 def current_col @col_topleft + @col_index end |
#current_row ⇒ Object
468 469 470 |
# File 'lib/spreadshoot.rb', line 468 def current_row @row_topleft + @row_index end |
#row(options = {}) {|row| ... } ⇒ Object
454 455 456 457 458 459 460 461 462 463 464 465 466 |
# File 'lib/spreadshoot.rb', line 454 def row = {} row = Row.new(self, ) yield(row) if block_given? if @direction == :vertical self.row_index += 1 self.col_index = 0 else self.col_index += 1 self.row_index = 0 end row end |