Class: Luck::Alert
Instance Attribute Summary collapse
-
#handler ⇒ Object
Returns the value of attribute handler.
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from Pane
#controls, #dirty, #display, #title, #visible
Instance Method Summary collapse
- #handle_char(char) ⇒ Object
-
#initialize(display, width, height, title, controls = {}, &blck) ⇒ Alert
constructor
A new instance of Alert.
- #on_dismiss(&blck) ⇒ Object
- #x1 ⇒ Object
- #x2 ⇒ Object
- #y1 ⇒ Object
- #y2 ⇒ Object
Methods inherited from Pane
#[], #control, #control_at, #dirty!, #draw_contents, #draw_frame, #draw_title, #handle_click, #hide!, #on_submit, #redraw, #show!, #yank_values
Constructor Details
#initialize(display, width, height, title, controls = {}, &blck) ⇒ Alert
Returns a new instance of Alert.
5 6 7 8 9 |
# File 'lib/luck/alert.rb', line 5 def initialize display, width, height, title, controls={}, &blck super display, nil, nil, nil, nil, title, controls, &blck @width, @height = width, height end |
Instance Attribute Details
#handler ⇒ Object
Returns the value of attribute handler.
3 4 5 |
# File 'lib/luck/alert.rb', line 3 def handler @handler end |
#height ⇒ Object
Returns the value of attribute height.
3 4 5 |
# File 'lib/luck/alert.rb', line 3 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
3 4 5 |
# File 'lib/luck/alert.rb', line 3 def width @width end |
Instance Method Details
#handle_char(char) ⇒ Object
29 30 31 32 33 34 |
# File 'lib/luck/alert.rb', line 29 def handle_char char if char == "\n" @handler.call @text if @handler end #redraw end |
#on_dismiss(&blck) ⇒ Object
25 26 27 |
# File 'lib/luck/alert.rb', line 25 def on_dismiss &blck @handler = blck end |
#x1 ⇒ Object
11 12 13 |
# File 'lib/luck/alert.rb', line 11 def x1 (@display.width / 2).to_i - (@width / 2).to_i end |
#x2 ⇒ Object
18 19 20 |
# File 'lib/luck/alert.rb', line 18 def x2 x1 + @width end |
#y1 ⇒ Object
14 15 16 |
# File 'lib/luck/alert.rb', line 14 def y1 (@display.height / 2).to_i - (@height / 2).to_i end |
#y2 ⇒ Object
21 22 23 |
# File 'lib/luck/alert.rb', line 21 def y2 y1 + @height end |