Sha256: 5241474955930011a0996491d755ab543800e774848a9ddaf367fc91f6c54328

Contents?: true

Size: 483 Bytes

Versions: 2

Compression:

Stored size: 483 Bytes

Contents

class Array
  def to_i
    self.map do |arg| 
      begin
        case arg.upcase
          when 'J' then 11
          when 'Q' then 12
          when 'K' then 13
          when 'A' then 1
          else Integer(arg)
        end
      rescue ArgumentError
        raise "unknown digit: '#{arg}'"
      end
    end
  end
end

class String
  def to_p
    {'11' => 'J', '12' => 'Q', '13' => 'K'}.each {|digit, poker| self.gsub!(digit, poker)}
    self
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
24games-0.2.2 lib/calc24/ext.rb
24games-0.2.1 lib/calc24/ext.rb