Module: CDK::ExitConditions

Included in:
CDKOBJS
Defined in:
lib/cdk/mixins/exit_conditions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#exit_typeObject (readonly)

Returns the value of attribute exit_type.



3
4
5
# File 'lib/cdk/mixins/exit_conditions.rb', line 3

def exit_type
  @exit_type
end

Instance Method Details

#init_exit_conditionsObject



5
6
7
8
# File 'lib/cdk/mixins/exit_conditions.rb', line 5

def init_exit_conditions
  # set default exit-types
  @exit_type = :NEVER_ACTIVATED
end

#resetExitTypeObject



26
27
28
# File 'lib/cdk/mixins/exit_conditions.rb', line 26

def resetExitType
  @exit_type = :NEVER_ACTIVATED
end

#setExitType(ch) ⇒ Object

Set the object’s exit-type based on the input. The .exitType field should have been part of the CDKOBJS struct, but it is used too pervasively in older applications to move (yet).



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/cdk/mixins/exit_conditions.rb', line 13

def setExitType(ch)
  case ch
  when CDK::KEY_ESC
    @exit_type = :ESCAPE_HIT
  when CDK::KEY_TAB, Ncurses::KEY_ENTER, CDK::KEY_RETURN
    @exit_type = :NORMAL
  when Ncurses::ERR
    @exit_type = :TIMEOUT
  when 0
    @exit_type = :EARLY_EXIT
  end
end