Class: Luck::Alert

Inherits:
Pane
  • Object
show all
Defined in:
lib/luck/alert.rb

Instance Attribute Summary collapse

Attributes inherited from Pane

#controls, #dirty, #display, #title, #visible

Instance Method Summary collapse

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

#handlerObject

Returns the value of attribute handler.



3
4
5
# File 'lib/luck/alert.rb', line 3

def handler
  @handler
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/luck/alert.rb', line 3

def height
  @height
end

#widthObject

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

#x1Object



11
12
13
# File 'lib/luck/alert.rb', line 11

def x1
  (@display.width / 2).to_i - (@width / 2).to_i
end

#x2Object



18
19
20
# File 'lib/luck/alert.rb', line 18

def x2
  x1 + @width
end

#y1Object



14
15
16
# File 'lib/luck/alert.rb', line 14

def y1
  (@display.height / 2).to_i - (@height / 2).to_i
end

#y2Object



21
22
23
# File 'lib/luck/alert.rb', line 21

def y2
  y1 + @height
end