Class: GlimmerKlondikeSolitaire::Model::Game
- Inherits:
-
Object
- Object
- GlimmerKlondikeSolitaire::Model::Game
- Defined in:
- app/glimmer_klondike_solitaire/model/game.rb
Constant Summary collapse
- COLUMN_PILE_COUNT =
7
Instance Attribute Summary collapse
-
#column_piles ⇒ Object
readonly
Returns the value of attribute column_piles.
-
#dealing_pile ⇒ Object
readonly
Returns the value of attribute dealing_pile.
-
#dealt_pile ⇒ Object
readonly
Returns the value of attribute dealt_pile.
-
#deck ⇒ Object
readonly
Returns the value of attribute deck.
-
#foundation_piles ⇒ Object
readonly
Returns the value of attribute foundation_piles.
Instance Method Summary collapse
-
#initialize ⇒ Game
constructor
A new instance of Game.
- #restart! ⇒ Object
Constructor Details
#initialize ⇒ Game
Returns a new instance of Game.
14 15 16 17 18 19 20 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 14 def initialize @deck = new_deck @dealt_pile = DealtPile.new(self) @dealing_pile = DealingPile.new(self) @column_piles = COLUMN_PILE_COUNT.times.map {|n| ColumnPile.new(self, n + 1)} @foundation_piles = PlayingCard::SUITS.map {|suit| FoundationPile.new(self, suit)} end |
Instance Attribute Details
#column_piles ⇒ Object (readonly)
Returns the value of attribute column_piles.
12 13 14 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12 def column_piles @column_piles end |
#dealing_pile ⇒ Object (readonly)
Returns the value of attribute dealing_pile.
12 13 14 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12 def dealing_pile @dealing_pile end |
#dealt_pile ⇒ Object (readonly)
Returns the value of attribute dealt_pile.
12 13 14 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12 def dealt_pile @dealt_pile end |
#deck ⇒ Object (readonly)
Returns the value of attribute deck.
12 13 14 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12 def deck @deck end |
#foundation_piles ⇒ Object (readonly)
Returns the value of attribute foundation_piles.
12 13 14 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 12 def foundation_piles @foundation_piles end |
Instance Method Details
#restart! ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/glimmer_klondike_solitaire/model/game.rb', line 22 def restart! @deck = new_deck @dealt_pile.reset! @dealing_pile.reset! @column_piles.each(&:reset!) @foundation_piles.each(&:reset!) end |