Sha256: 5bbfa77c322d2d9675fb1f8b956e2da776c74a7751d4e72a2bbb36ad98159b40

Contents?: true

Size: 987 Bytes

Versions: 4

Compression:

Stored size: 987 Bytes

Contents

module Notesgrip
  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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
notesgrip-0.0.8 lib/notesgrip/GripWrapper.rb
notesgrip-0.0.7 lib/notesgrip/GripWrapper.rb
notesgrip-0.0.5 lib/notesgrip/GripWrapper.rb
notesgrip-0.0.4 lib/notesgrip/GripWrapper.rb