Class: Sheet
- Inherits:
-
Object
- Object
- Sheet
- Includes:
- Enumerable
- Defined in:
- lib/solis/shape/reader/simple_sheets/sheet.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #count ⇒ Object
- #each ⇒ Object
- #header ⇒ Object
-
#initialize(worksheet) ⇒ Sheet
constructor
A new instance of Sheet.
- #title ⇒ Object
Constructor Details
#initialize(worksheet) ⇒ Sheet
Returns a new instance of Sheet.
3 4 5 6 |
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 3 def initialize(worksheet) @worksheet = worksheet @last_sync = Time.now end |
Instance Method Details
#[](index) ⇒ Object
22 23 24 |
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 22 def [](index) row_as_record(@worksheet.rows(skip=0)[index]) end |
#count ⇒ Object
26 27 28 |
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 26 def count @worksheet.num_rows - 1 end |
#each ⇒ Object
12 13 14 15 16 |
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 12 def each @worksheet.rows(skip=1).each do |row| yield make_record_from_row(row) end end |
#header ⇒ Object
18 19 20 |
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 18 def header @header ||= @worksheet.rows[0].map{|m| m.downcase.gsub(' ','_').gsub('#', '_hash').gsub('%','_percent')} end |
#title ⇒ Object
8 9 10 |
# File 'lib/solis/shape/reader/simple_sheets/sheet.rb', line 8 def title @worksheet.title end |