sliceable switch implementation in Ruby