Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/calc24/ext.rb

Instance Method Summary collapse

Instance Method Details

#to_iObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/calc24/ext.rb', line 10

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

#to_pObject



24
25
26
27
# File 'lib/calc24/ext.rb', line 24

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