Class: Saxlsx::Sheet
- Inherits:
-
Object
- Object
- Saxlsx::Sheet
- Defined in:
- lib/saxlsx/sheet.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name, index, file_system, workbook) ⇒ Sheet
constructor
A new instance of Sheet.
- #rows ⇒ Object
- #to_csv(path) ⇒ Object
Constructor Details
#initialize(name, index, file_system, workbook) ⇒ Sheet
Returns a new instance of Sheet.
7 8 9 10 11 12 |
# File 'lib/saxlsx/sheet.rb', line 7 def initialize(name, index, file_system, workbook) @name = name @index = index @file_system = file_system @workbook = workbook end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/saxlsx/sheet.rb', line 5 def name @name end |
Instance Method Details
#rows ⇒ Object
14 15 16 |
# File 'lib/saxlsx/sheet.rb', line 14 def rows @rows ||= RowsCollection.new(@index, @file_system, @workbook) end |
#to_csv(path) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/saxlsx/sheet.rb', line 18 def to_csv(path) FileUtils.mkpath path unless Dir.exists? path File.open("#{path}/#{name}.csv", 'w') do |f| rows.each do |row| f.puts row.map{|c| "\"#{c}\""}.join(',') end end end |