Class: ExcelUtils::Sheet
- Inherits:
-
Object
- Object
- ExcelUtils::Sheet
- Includes:
- Enumerable
- Defined in:
- lib/excel_utils/sheet.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#normalize_column_names ⇒ Object
readonly
Returns the value of attribute normalize_column_names.
Instance Method Summary collapse
- #column_names ⇒ Object
- #each(&block) ⇒ Object
-
#initialize(name, spreadsheet, normalize_column_names: false) ⇒ Sheet
constructor
A new instance of Sheet.
Constructor Details
#initialize(name, spreadsheet, normalize_column_names: false) ⇒ Sheet
Returns a new instance of Sheet.
8 9 10 11 12 |
# File 'lib/excel_utils/sheet.rb', line 8 def initialize(name, spreadsheet, normalize_column_names: false) @name = name @spreadsheet = spreadsheet @normalize_column_names = normalize_column_names end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/excel_utils/sheet.rb', line 6 def name @name end |
#normalize_column_names ⇒ Object (readonly)
Returns the value of attribute normalize_column_names.
6 7 8 |
# File 'lib/excel_utils/sheet.rb', line 6 def normalize_column_names @normalize_column_names end |
Instance Method Details
#column_names ⇒ Object
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/excel_utils/sheet.rb', line 14 def column_names @column_names ||= begin if sheet.first_row first_row = sheet.row sheet.first_row normalize_column_names ? first_row.map { |name| normalize_column name } : first_row else [] end end end |
#each(&block) ⇒ Object
25 26 27 |
# File 'lib/excel_utils/sheet.rb', line 25 def each(&block) rows.each(&block) end |