Class: Pontifex::Card
- Inherits:
-
Object
- Object
- Pontifex::Card
- Defined in:
- lib/pontifex/card.rb
Instance Attribute Summary collapse
-
#str ⇒ Object
readonly
Returns the value of attribute str.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(input_str) ⇒ Card
constructor
A new instance of Card.
- #to_c ⇒ Object
- #to_i ⇒ Object
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
#str ⇒ Object (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_c ⇒ Object
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_i ⇒ Object
10 11 12 |
# File 'lib/pontifex/card.rb', line 10 def to_i @value end |