Class: Bmg::Database::Xlsx
- Inherits:
-
Bmg::Database
- Object
- Bmg::Database
- Bmg::Database::Xlsx
- Defined in:
- lib/bmg/database/xlsx.rb
Constant Summary collapse
- DEFAULT_OPTIONS =
{ reader_options: {} }
Instance Method Summary collapse
- #each_relation_pair ⇒ Object
-
#initialize(path, options = {}) ⇒ Xlsx
constructor
A new instance of Xlsx.
- #method_missing(name, *args, &bl) ⇒ Object
Methods inherited from Bmg::Database
data_folder, #output_preferences_for, sequel, #to_data_folder, #to_xlsx, xlsx
Constructor Details
#initialize(path, options = {}) ⇒ Xlsx
Returns a new instance of Xlsx.
9 10 11 12 13 |
# File 'lib/bmg/database/xlsx.rb', line 9 def initialize(path, = {}) path = Path(path) if path.is_a?(String) @path = path @options = DEFAULT_OPTIONS.merge() end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &bl) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/bmg/database/xlsx.rb', line 15 def method_missing(name, *args, &bl) return super(name, *args, &bl) unless args.empty? && bl.nil? rel = rel_for(name) raise NotSuchRelationError(name.to_s) unless rel rel end |
Instance Method Details
#each_relation_pair ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bmg/database/xlsx.rb', line 22 def each_relation_pair return to_enum(:each_relation_pair) unless block_given? spreadsheet.sheets.each do |sheet_name| yield(sheet_name.to_sym, rel_for(sheet_name)) end end |