Class: ExcelUtils::Workbooks::CSV
- Inherits:
-
Object
- Object
- ExcelUtils::Workbooks::CSV
- Defined in:
- lib/excel_utils/workbooks/csv.rb
Constant Summary collapse
- SHEET_NAME =
'default'.freeze
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#normalize_column_names ⇒ Object
readonly
Returns the value of attribute normalize_column_names.
Instance Method Summary collapse
- #[](sheet_name) ⇒ Object
-
#initialize(filename, normalize_column_names: false) ⇒ CSV
constructor
A new instance of CSV.
- #sheets ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(filename, normalize_column_names: false) ⇒ CSV
9 10 11 12 13 14 15 16 |
# File 'lib/excel_utils/workbooks/csv.rb', line 9 def initialize(filename, normalize_column_names: false) @filename = filename @normalize_column_names = normalize_column_names @sheet = Sheets::CSV.new name: SHEET_NAME, normalize_column_names: normalize_column_names, filename: filename end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
7 8 9 |
# File 'lib/excel_utils/workbooks/csv.rb', line 7 def filename @filename end |
#normalize_column_names ⇒ Object (readonly)
Returns the value of attribute normalize_column_names.
7 8 9 |
# File 'lib/excel_utils/workbooks/csv.rb', line 7 def normalize_column_names @normalize_column_names end |
Instance Method Details
#[](sheet_name) ⇒ Object
22 23 24 |
# File 'lib/excel_utils/workbooks/csv.rb', line 22 def [](sheet_name) sheet_name == SHEET_NAME ? sheet : nil end |
#sheets ⇒ Object
18 19 20 |
# File 'lib/excel_utils/workbooks/csv.rb', line 18 def sheets [sheet] end |
#to_h ⇒ Object
26 27 28 |
# File 'lib/excel_utils/workbooks/csv.rb', line 26 def to_h {SHEET_NAME => sheet.to_a} end |