Class: BOARD::B::C
- Inherits:
-
Object
- Object
- BOARD::B::C
- Defined in:
- lib/toychest/board.rb
Instance Attribute Summary collapse
-
#board ⇒ Object
readonly
Returns the value of attribute board.
Instance Method Summary collapse
- #[](k) ⇒ Object
- #[]=(k, v) ⇒ Object
-
#initialize(k, c) ⇒ C
constructor
A new instance of C.
- #on(k, h = {}, &b) ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(k, c) ⇒ C
Returns a new instance of C.
16 17 18 19 20 |
# File 'lib/toychest/board.rb', line 16 def initialize k, c @board, @cell = k, c @h = {} @on = {} end |
Instance Attribute Details
#board ⇒ Object (readonly)
Returns the value of attribute board.
15 16 17 |
# File 'lib/toychest/board.rb', line 15 def board @board end |
Instance Method Details
#[](k) ⇒ Object
21 22 23 |
# File 'lib/toychest/board.rb', line 21 def [] k @h[k] end |
#[]=(k, v) ⇒ Object
24 25 26 |
# File 'lib/toychest/board.rb', line 24 def []= k,v @h[k] = v end |
#on(k, h = {}, &b) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/toychest/board.rb', line 27 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 BOARD.on.has_key? k BOARD.on[k].call(self, k, h) else BOARD.on[:default].call(self, k, h) end end end end |
#to_h ⇒ Object
42 43 44 |
# File 'lib/toychest/board.rb', line 42 def to_h @h end |