Skip to content

Instantly share code, notes, and snippets.

@acook
Last active December 23, 2015 11:59
Show Gist options
  • Save acook/6ad6cacf94f896353970 to your computer and use it in GitHub Desktop.
Save acook/6ad6cacf94f896353970 to your computer and use it in GitHub Desktop.
class Foo
class XY
def initialize x, y
@x, @y = x, y
end
attr :x, :y
def limit *args
[x, y].max
end
end
def initialize *args
case
when args.count == 1 && args[0].is_a?(Fixnum)
x, y, z = resolve(args[0])
when args.count == 3
x, y, z = args
end
@xy = XY.new(x, y)
raise ArgumentError, 'z cannot be converted to an integer' unless z.respond_to?(:to_i)
raise 'x does not exist' unless (1..@xy.limit).cover? z.to_i
@number = z.to_i
end
end
begin
Foo.new
rescue => error
puts "RESCUING from: #{error.class}::#{error.message}"
binding.pry
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment