Module: Rxl
- Defined in:
- lib/rxl.rb,
lib/rxl/version.rb
Constant Summary collapse
- VERSION =
"0.6.1"
Class Method Summary collapse
- .read_file(filepath) ⇒ Object
- .read_file_as_tables(filepath) ⇒ Object
- .read_files(filepaths_hash, read_style = nil) ⇒ Object
- .write_file(filepath, hash_workbook) ⇒ Object
- .write_file_as_tables(filepath, hash_tables, write_headers: true) ⇒ Object
Class Method Details
.read_file(filepath) ⇒ Object
19 20 21 22 |
# File 'lib/rxl.rb', line 19 def self.read_file(filepath) rubyxl_workbook = RubyXL::Parser.parse(filepath) Workbook.rubyxl_to_hash(rubyxl_workbook) end |
.read_file_as_tables(filepath) ⇒ Object
24 25 26 27 |
# File 'lib/rxl.rb', line 24 def self.read_file_as_tables(filepath) hash_workbook = read_file(filepath) Workbook.hash_workbook_to_hash_tables(hash_workbook) end |
.read_files(filepaths_hash, read_style = nil) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/rxl.rb', line 29 def self.read_files(filepaths_hash, read_style = nil) return_hash = {} filepaths_hash.each do |key, value| if read_style == :as_tables return_hash[key] = read_file_as_tables(value) else return_hash[key] = read_file(value) end end return_hash end |
.write_file(filepath, hash_workbook) ⇒ Object
7 8 9 10 11 |
# File 'lib/rxl.rb', line 7 def self.write_file(filepath, hash_workbook) rubyxl_workbook = Workbook.hash_workbook_to_rubyxl_workbook(hash_workbook) rubyxl_workbook.write(filepath) nil end |
.write_file_as_tables(filepath, hash_tables, write_headers: true) ⇒ Object
13 14 15 16 17 |
# File 'lib/rxl.rb', line 13 def self.write_file_as_tables(filepath, hash_tables, write_headers: true) hash_workbook = Workbook.hashes_to_hash_workbook(hash_tables, write_headers: write_headers) write_file(filepath, hash_workbook) nil end |