lib/ppcurses/actions/GetBooleanAction.rb in ppcurses-0.0.20 vs lib/ppcurses/actions/GetBooleanAction.rb in ppcurses-0.0.21
- old
+ new
@@ -1,46 +1,47 @@
require_relative 'PromptAction.rb'
+#noinspection RubyResolve
module PPCurses
class GetBooleanAction < PromptAction
def initialize(prompt)
super(prompt)
- @state = false;
+ @state = false
end
- def printPrompt()
+ def print_prompt
super()
- @win.addstr("No [")
- if (@state == false) then @win.addstr("X") else @win.addstr(" ") end
- @win.addstr("] Yes [")
- if (@state == true) then @win.addstr("X") else @win.addstr(" ") end
- @win.addstr("]")
+ @win.addstr('No [')
+ if @state then @win.addstr(' ') else @win.addstr('X') end
+ @win.addstr('] Yes [')
+ if @state then @win.addstr('X') else @win.addstr(' ') end
+ @win.addstr(']')
end
- def execute()
- printPrompt()
+ def execute
+ print_prompt()
# Enables reading arrow keys in getch
@win.keypad(true)
- while(1)
+ while 1
noecho
c = @win.getch
if c == KEY_LEFT then @state = false end
if c == KEY_RIGHT then @state = true end
if c == 10 then break end
echo
- printPrompt()
+ print_prompt()
end
echo
end
def data
- if @state == false then return "0" end
- "1"
+ if @state then return '1' end
+ '0'
end
end
end