-
-
Save acook/6ad6cacf94f896353970 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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