Class: Toychest::C

Inherits:
Object
  • Object
show all
Defined in:
lib/toychest.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bagObject (readonly)

Returns the value of attribute bag.



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

def bag
  @bag
end

#boardObject (readonly)

Returns the value of attribute board.



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

def board
  @board
end

#cardObject (readonly)

Returns the value of attribute card.



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

def card
  @card
end

Returns the value of attribute cookie.



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

def cookie
  @cookie
end

#diceObject (readonly)

Returns the value of attribute dice.



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

def dice
  @dice
end

#lottoObject (readonly)

Returns the value of attribute lotto.



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

def lotto
  @lotto
end

#pieceObject (readonly)

Returns the value of attribute piece.



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

def piece
  @piece
end

#tileObject (readonly)

Returns the value of attribute tile.



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

def tile
  @tile
end

#zodiacObject (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