Class: Toychest::C
- Inherits:
-
Object
- Object
- Toychest::C
- Defined in:
- lib/toychest.rb
Instance Attribute Summary collapse
-
#bag ⇒ Object
readonly
Returns the value of attribute bag.
-
#board ⇒ Object
readonly
Returns the value of attribute board.
-
#card ⇒ Object
readonly
Returns the value of attribute card.
-
#cookie ⇒ Object
readonly
Returns the value of attribute cookie.
-
#dice ⇒ Object
readonly
Returns the value of attribute dice.
-
#lotto ⇒ Object
readonly
Returns the value of attribute lotto.
-
#piece ⇒ Object
readonly
Returns the value of attribute piece.
-
#tile ⇒ Object
readonly
Returns the value of attribute tile.
-
#zodiac ⇒ Object
readonly
Returns the value of attribute zodiac.
Instance Method Summary collapse
- #[](k) ⇒ Object
-
#initialize(k) ⇒ C
constructor
A new instance of C.
- #on(k, h = {}, &b) ⇒ Object
- #turn(h = {}, &b) ⇒ Object
Constructor Details
#initialize(k) ⇒ C
Returns a new instance of C.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/toychest.rb', line 47 def initialize k @id = k @on = {} @bag = BAG[@id] @board = BOARD[@id] @piece = PIECE[@id] @tile = TILE[@id] @card = CARD[@id] @dice = DICE[@id] @lotto = LOTTO[@id] @cookie = COOKIE[@id] @zodiac = ZODIAC[@id] @h = { bank: @bank, bag: @bag, board: @board, piece: @piece, tile: @tile, card: @card, dice: @dice, lotto: @lotto, cookie: @cookie, zodiac: @zodiac } end |
Instance Attribute Details
#bag ⇒ Object (readonly)
Returns the value of attribute bag.
46 47 48 |
# File 'lib/toychest.rb', line 46 def bag @bag end |
#board ⇒ Object (readonly)
Returns the value of attribute board.
46 47 48 |
# File 'lib/toychest.rb', line 46 def board @board end |
#card ⇒ Object (readonly)
Returns the value of attribute card.
46 47 48 |
# File 'lib/toychest.rb', line 46 def card @card end |
#cookie ⇒ Object (readonly)
Returns the value of attribute cookie.
46 47 48 |
# File 'lib/toychest.rb', line 46 def @cookie end |
#dice ⇒ Object (readonly)
Returns the value of attribute dice.
46 47 48 |
# File 'lib/toychest.rb', line 46 def dice @dice end |
#lotto ⇒ Object (readonly)
Returns the value of attribute lotto.
46 47 48 |
# File 'lib/toychest.rb', line 46 def lotto @lotto end |
#piece ⇒ Object (readonly)
Returns the value of attribute piece.
46 47 48 |
# File 'lib/toychest.rb', line 46 def piece @piece end |
#tile ⇒ Object (readonly)
Returns the value of attribute tile.
46 47 48 |
# File 'lib/toychest.rb', line 46 def tile @tile end |
#zodiac ⇒ Object (readonly)
Returns the value of attribute zodiac.
46 47 48 |
# File 'lib/toychest.rb', line 46 def zodiac @zodiac end |
Instance Method Details
#[](k) ⇒ Object
72 73 74 |
# File 'lib/toychest.rb', line 72 def [] k @h[k] end |
#on(k, h = {}, &b) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/toychest.rb', line 78 def on k, h={}, &b if block_given? @on[k] = b else if @on.has_key? k @on[k].call(self, k, h) else if Toychest.on.has_key? k Toychest.on[k].call(self, k, h) else Toychest.on[:default].call(self, k, h) end end end end |
#turn(h = {}, &b) ⇒ Object
75 76 77 |
# File 'lib/toychest.rb', line 75 def turn h={}, &b b.call(self, h) end |