Class: Shithead::Player
- Inherits:
-
Object
- Object
- Shithead::Player
- Defined in:
- lib/shithead/player.rb
Instance Attribute Summary collapse
-
#hand ⇒ Object
readonly
Returns the value of attribute hand.
-
#hidden ⇒ Object
readonly
Returns the value of attribute hidden.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#visible ⇒ Object
readonly
Returns the value of attribute visible.
Instance Method Summary collapse
- #add(card) ⇒ Object
- #clear? ⇒ Boolean
- #hand_count ⇒ Object
- #hidden_count ⇒ Object
-
#initialize(name) ⇒ Player
constructor
A new instance of Player.
Constructor Details
#initialize(name) ⇒ Player
Returns a new instance of Player.
4 5 6 7 8 9 |
# File 'lib/shithead/player.rb', line 4 def initialize(name) @name = name @hidden = [] @visible = Shithead::SortedStack.new @hand = Shithead::SortedStack.new end |
Instance Attribute Details
#hand ⇒ Object (readonly)
Returns the value of attribute hand.
2 3 4 |
# File 'lib/shithead/player.rb', line 2 def hand @hand end |
#hidden ⇒ Object (readonly)
Returns the value of attribute hidden.
2 3 4 |
# File 'lib/shithead/player.rb', line 2 def hidden @hidden end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/shithead/player.rb', line 2 def name @name end |
#visible ⇒ Object (readonly)
Returns the value of attribute visible.
2 3 4 |
# File 'lib/shithead/player.rb', line 2 def visible @visible end |
Instance Method Details
#add(card) ⇒ Object
11 12 13 |
# File 'lib/shithead/player.rb', line 11 def add(card) hand.add card end |
#clear? ⇒ Boolean
15 16 17 |
# File 'lib/shithead/player.rb', line 15 def clear? hidden.empty? && visible.empty? && hand.empty? end |
#hand_count ⇒ Object
19 20 21 |
# File 'lib/shithead/player.rb', line 19 def hand_count hand.length end |
#hidden_count ⇒ Object
23 24 25 |
# File 'lib/shithead/player.rb', line 23 def hidden_count hidden.length end |