Class: Rasta::Spreadsheet::Record
- Inherits:
-
Object
- Object
- Rasta::Spreadsheet::Record
- Defined in:
- lib/rasta/spreadsheet.rb
Overview
Records store the information of a particular row/col of a worksheet and allow iterating through the Record’s Cells
Instance Attribute Summary collapse
-
#book ⇒ Object
readonly
Returns the value of attribute book.
-
#recordindex ⇒ Object
readonly
Returns the value of attribute recordindex.
-
#sheet ⇒ Object
readonly
Returns the value of attribute sheet.
Instance Method Summary collapse
- #[](index) ⇒ Object
- #color=(c) ⇒ Object
- #dump ⇒ Object
- #each ⇒ Object
-
#initialize(sheet, index) ⇒ Record
constructor
A new instance of Record.
- #select ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(sheet, index) ⇒ Record
Returns a new instance of Record.
405 406 407 408 409 410 |
# File 'lib/rasta/spreadsheet.rb', line 405 def initialize(sheet, index) @sheet = sheet @book = sheet.book @recordindex = index @range = @sheet.cellrange(@recordindex) end |
Instance Attribute Details
#book ⇒ Object (readonly)
Returns the value of attribute book.
404 405 406 |
# File 'lib/rasta/spreadsheet.rb', line 404 def book @book end |
#recordindex ⇒ Object (readonly)
Returns the value of attribute recordindex.
404 405 406 |
# File 'lib/rasta/spreadsheet.rb', line 404 def recordindex @recordindex end |
#sheet ⇒ Object (readonly)
Returns the value of attribute sheet.
404 405 406 |
# File 'lib/rasta/spreadsheet.rb', line 404 def sheet @sheet end |
Instance Method Details
#[](index) ⇒ Object
426 427 428 |
# File 'lib/rasta/spreadsheet.rb', line 426 def [](index) Cell.new(@sheet, @recordindex, index) end |
#color=(c) ⇒ Object
423 424 425 |
# File 'lib/rasta/spreadsheet.rb', line 423 def color=(c) @range.Interior.ColorIndex = c end |
#dump ⇒ Object
432 433 434 435 436 |
# File 'lib/rasta/spreadsheet.rb', line 432 def dump vals = [] self.each { |cell| vals << cell.value } return vals end |
#each ⇒ Object
411 412 413 414 415 416 417 418 419 |
# File 'lib/rasta/spreadsheet.rb', line 411 def each @sheet.headers.each_index do |cell_index| # should be a value for each header cell = @sheet.cell(@recordindex,cell_index + 1) next if cell.nil? # Make sure the header exists # Skip empty cells and italicized cells next if (cell.value == '' || cell.italic) yield cell end end |
#select ⇒ Object
420 421 422 |
# File 'lib/rasta/spreadsheet.rb', line 420 def select @range.Select end |
#to_s ⇒ Object
429 430 431 |
# File 'lib/rasta/spreadsheet.rb', line 429 def to_s @sheet.style.to_s + ':' + @recordindex.to_s end |