Class: Patience::Card::Rank

Inherits:
Object show all
Defined in:
lib/patience/rank.rb

Overview

Rank class provides underlying methods for every rank.

Instance Method Summary collapse

Instance Method Details

#<=>(other_rank) ⇒ Object

Compares two ranks with each other. Based on integer values.



38
39
40
# File 'lib/patience/rank.rb', line 38

def <=>(other_rank)
  @num <=> other_rank.to_i
end

#ace?Boolean

Returns:

  • (Boolean)


42
# File 'lib/patience/rank.rb', line 42

def ace?;   @num == 1;  end

#higher_by_one_than?(other_rank) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/patience/rank.rb', line 46

def higher_by_one_than?(other_rank)
  @num - other_rank.to_i == 1
end

#king?Boolean

Returns:

  • (Boolean)


43
# File 'lib/patience/rank.rb', line 43

def king?;  @num == 13; end

#queen?Boolean

Returns:

  • (Boolean)


44
# File 'lib/patience/rank.rb', line 44

def queen?; @num == 12; end

#to_sObject

Returns string representation of a rank. It asks class to give its full name, exscinding everything but its actual name.



33
34
35
# File 'lib/patience/rank.rb', line 33

def to_s
  "#{self.class.name.demodulize}"
end