Class: Demos::TicTacToe::Square
Instance Attribute Summary
#node, #provides, #publisher
Instance Method Summary
collapse
#children, #children?, compile, computed, computed!, #draw, #draw_with, #dump, #emit, #initialize, inject, inject!, #method_missing, mount, #on_resize, provide, provides, #render, style, styles_get, template, template_from_file, template_get, #update, use, uses
Constructor Details
This class inherits a constructor from Hokusai::Block
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Hokusai::Block
Instance Method Details
#compute_background ⇒ Object
44
45
46
47
48
49
50
51
52
53
|
# File 'ui/examples/tic_tac_toe.rb', line 44
def compute_background
case player
when Player::X
[52,168,77]
when Player::O
[219,176,57]
when Player::None
@hover ? [55, 110, 155] : [47,98,140]
end
end
|
#emit_position(click) ⇒ Object
67
68
69
|
# File 'ui/examples/tic_tac_toe.rb', line 67
def emit_position(click)
emit("position", position)
end
|
#has_player ⇒ Object
71
72
73
|
# File 'ui/examples/tic_tac_toe.rb', line 71
def has_player
player != Player::None
end
|
#read_position ⇒ Object
63
64
65
|
# File 'ui/examples/tic_tac_toe.rb', line 63
def read_position
position.inspect
end
|
#set_hover(event) ⇒ Object
55
56
57
|
# File 'ui/examples/tic_tac_toe.rb', line 55
def set_hover(event)
@hover = true
end
|
#set_mouseout(event) ⇒ Object
59
60
61
|
# File 'ui/examples/tic_tac_toe.rb', line 59
def set_mouseout(event)
@hover = false
end
|
#square_image ⇒ Object
75
76
77
78
79
80
81
82
|
# File 'ui/examples/tic_tac_toe.rb', line 75
def square_image
case player
when Player::X
return "#{__dir__}/assets/science-troll.png"
when Player::O
return "#{__dir__}/assets/football-troll.png"
end
end
|