Class: DataShift::Excel
- Inherits:
-
Object
- Object
- DataShift::Excel
- Defined in:
- lib/applications/excel.rb
Overview
< BasicObject
Class Method Summary collapse
-
.const_missing(name) ⇒ Object
without this can’t get at any defined modules etc.
- .method_missing(method, *args, &block) ⇒ Object
Instance Method Summary collapse
-
#initialize ⇒ Excel
constructor
A new instance of Excel.
-
#method_missing(method, *args, &block) ⇒ Object
Forward all undefined methods to the wrapped Excel object.
-
#respond_to?(method, include_private = false) ⇒ Boolean
Returns
true
if obj responds to the given method.
Constructor Details
#initialize ⇒ Excel
Returns a new instance of Excel.
43 44 45 46 |
# File 'lib/applications/excel.rb', line 43 def initialize @excel_class = ExcelProxy.proxy_class @excel = ExcelProxy.proxy_object end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Forward all undefined methods to the wrapped Excel object.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/applications/excel.rb', line 49 def method_missing(method, *args, &block) # puts @excel.class, method, args.inspect if @excel.respond_to?(method) @excel.send(method, *args, &block) elsif @excel.worksheets.last.respond_to?(method) # active_worksheet doesn't work so use the latest @excel.worksheets.last.send(method, *args, &block) elsif @excel_class.respond_to?(method) if method == :open || method == 'open' @excel = @excel_class.send(method, *args, &block) else @excel_class.send(method, *args, &block) end else super end end |
Class Method Details
.const_missing(name) ⇒ Object
without this can’t get at any defined modules etc
79 80 81 |
# File 'lib/applications/excel.rb', line 79 def self.const_missing(name) ::Object.const_get(name) end |
.method_missing(method, *args, &block) ⇒ Object
67 68 69 |
# File 'lib/applications/excel.rb', line 67 def self.method_missing(method, *args, &block) @excel_class.send(method, *args, &block) end |
Instance Method Details
#respond_to?(method, include_private = false) ⇒ Boolean
Returns true
if obj responds to the given method. Private methods are included in the search only if the optional second parameter evaluates to true
.
73 74 75 |
# File 'lib/applications/excel.rb', line 73 def respond_to?(method, include_private = false) super || @excel.respond_to?(method, include_private) end |