class Dottie::Freckle
Public Class Methods
new(obj)
click to toggle source
Creates a new Freckle
to wrap the supplied object.
# File lib/dottie/freckle.rb, line 8 def initialize(obj) case obj when Hash, Array @_wrapped_object = obj else raise TypeError, 'must be a Hash or Array' end end
Public Instance Methods
array()
click to toggle source
hash()
click to toggle source
inspect()
click to toggle source
# File lib/dottie/freckle.rb, line 45 def inspect "<Dottie::Freckle #{wrapped_object.inspect}>" end
method_missing(method, *args)
click to toggle source
# File lib/dottie/freckle.rb, line 49 def method_missing(method, *args) wrapped_object.send(method, *args) end
wrapped_object(type = nil)
click to toggle source
Returns the wrapped object, and raises an error if a type class is provided and the wrapped object is not of that type.
# File lib/dottie/freckle.rb, line 37 def wrapped_object(type = nil) if type.nil? || @_wrapped_object.is_a?(type) @_wrapped_object else raise TypeError.new("expected #{type.name} but got #{@_wrapped_object.class.name}") end end