Class: Pontifex::Card

Inherits:
Object
  • Object
show all
Defined in:
lib/pontifex/card.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input_str) ⇒ Card

Returns a new instance of Card.



5
6
7
8
# File 'lib/pontifex/card.rb', line 5

def initialize(input_str)
  @str = input_str
  @value = process_input(input_str)
end

Instance Attribute Details

#strObject (readonly)

Returns the value of attribute str.



3
4
5
# File 'lib/pontifex/card.rb', line 3

def str
  @str
end

Instance Method Details

#==(other) ⇒ Object



20
21
22
# File 'lib/pontifex/card.rb', line 20

def ==(other)
  self.str == other.str
end

#to_cObject



14
15
16
17
18
# File 'lib/pontifex/card.rb', line 14

def to_c
  return nil if str[0] == "j"
  letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split('')
  letters[(@value % 26) - 1]
end

#to_iObject



10
11
12
# File 'lib/pontifex/card.rb', line 10

def to_i
  @value
end