Sha256: c53c2c7b3f57c1536045d5d76827006bfdc6f3abcb5478bc6e291fde29881ed3

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

module Excelgrip
  class GripWrapper
    def initialize(raw_object)
      if raw_object.methods.include?("raw")
        @raw_object = raw_object.raw
      else
        @raw_object = raw_object
      end
    end
    
    def raw
      @raw_object
    end
    
    def inspect()
      "<#{self.class}>"
    end
    
    private
    
    OLE_METHODS = [:Type, :Initialize]
    def method_missing(m_id, *params)
      unless OLE_METHODS.include?(m_id)
        missing_method_name = m_id.to_s.downcase
        methods.each {|method|
          if method.to_s.downcase == missing_method_name
            return send(method, *params)
          end
        }
      end
      # Undefined Method is throwed to raw_object
      begin
        @raw_object.send(m_id, *params)
      rescue
        raise $!,$!.message, caller
      end
    end
    
    def toRaw(target_obj)
      target_obj.respond_to?("raw") ? target_obj.raw : target_obj
    end
  end
  
  class FileSystemObject
    include Singleton
    def initialize
      @body =  WIN32OLE.new('Scripting.FileSystemObject')
    end
    
    def fullpath(filename)
      @body.getAbsolutePathName(filename)
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
excelgrip-0.0.3 lib/excelgrip/GripWrapper.rb
excelgrip-0.0.2 lib/excelgrip/GripWrapper.rb