Skip to content

Instantly share code, notes, and snippets.

@krisleech
Created October 12, 2019 21:48
Show Gist options
  • Save krisleech/d6a79feabe5b098e970a5ca88a5305c8 to your computer and use it in GitHub Desktop.
Save krisleech/d6a79feabe5b098e970a5ca88a5305c8 to your computer and use it in GitHub Desktop.
Izzy case idea
class Izzy
  def initialize(sign, n)    
    @s = sign
    @n = n
  end

  def ===(other)
    other.send(@s, @n)
  end
end

def is?(sign, num)
  Izzy.new(sign, num)
end

include Izzy::Helper # is? method

case number
when is?(:>, 1)
  puts "> 1"
else
  puts "??"
end
case project
  when is?(:active)
  when is?(:finished)
  when is?(:older_than, 3.days)
end

case thing
  when is?
  when is_not?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment