Module: Vedeu::Terminal::Mode

Extended by:
Mode
Included in:
Vedeu::Terminal, Mode
Defined in:
lib/vedeu/terminal/mode.rb

Overview

Store the current mode of the terminal.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cooked_mode!Symbol

Sets the terminal in to ‘cooked` mode.

Returns:

  • (Symbol)


22
23
24
# File 'lib/vedeu/terminal/mode.rb', line 22

def cooked_mode!
  @mode = :cooked
end

.cooked_mode?Boolean

Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.

Returns:

  • (Boolean)


15
16
17
# File 'lib/vedeu/terminal/mode.rb', line 15

def cooked_mode?
  mode == :cooked
end

.fake_mode!Symbol

Sets the terminal in to ‘fake` mode.

Returns:

  • (Symbol)


37
38
39
# File 'lib/vedeu/terminal/mode.rb', line 37

def fake_mode!
  @mode = :fake
end

.fake_mode?Boolean

Returns a boolean indicating whether the terminal is currently in ‘fake` mode.

Returns:

  • (Boolean)


30
31
32
# File 'lib/vedeu/terminal/mode.rb', line 30

def fake_mode?
  mode == :fake
end

.modeSymbol

Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`. Can change throughout the lifespan of the client application.

Returns:

  • (Symbol)


72
73
74
# File 'lib/vedeu/terminal/mode.rb', line 72

def mode
  @mode ||= Vedeu::Configuration.terminal_mode
end

.raw_mode!Symbol

Sets the terminal in to ‘raw` mode.

Returns:

  • (Symbol)


52
53
54
# File 'lib/vedeu/terminal/mode.rb', line 52

def raw_mode!
  @mode = :raw
end

.raw_mode?Boolean

Returns a boolean indicating whether the terminal is currently in ‘raw` mode.

Returns:

  • (Boolean)


45
46
47
# File 'lib/vedeu/terminal/mode.rb', line 45

def raw_mode?
  mode == :raw
end

.switch_mode!Symbol

Toggles the terminal’s mode between ‘cooked`, `fake` and `raw`, depending on its current mode.

Returns:

  • (Symbol)


60
61
62
63
64
65
# File 'lib/vedeu/terminal/mode.rb', line 60

def switch_mode!
  return fake_mode!   if raw_mode?
  return cooked_mode! if fake_mode?

  raw_mode!
end

Instance Method Details

#cooked_mode!Symbol

Sets the terminal in to ‘cooked` mode.

Returns:

  • (Symbol)


22
23
24
# File 'lib/vedeu/terminal/mode.rb', line 22

def cooked_mode!
  @mode = :cooked
end

#cooked_mode?Boolean

Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.

Returns:

  • (Boolean)


15
16
17
# File 'lib/vedeu/terminal/mode.rb', line 15

def cooked_mode?
  mode == :cooked
end

#fake_mode!Symbol

Sets the terminal in to ‘fake` mode.

Returns:

  • (Symbol)


37
38
39
# File 'lib/vedeu/terminal/mode.rb', line 37

def fake_mode!
  @mode = :fake
end

#fake_mode?Boolean

Returns a boolean indicating whether the terminal is currently in ‘fake` mode.

Returns:

  • (Boolean)


30
31
32
# File 'lib/vedeu/terminal/mode.rb', line 30

def fake_mode?
  mode == :fake
end

#modeSymbol

Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`. Can change throughout the lifespan of the client application.

Returns:

  • (Symbol)


72
73
74
# File 'lib/vedeu/terminal/mode.rb', line 72

def mode
  @mode ||= Vedeu::Configuration.terminal_mode
end

#raw_mode!Symbol

Sets the terminal in to ‘raw` mode.

Returns:

  • (Symbol)


52
53
54
# File 'lib/vedeu/terminal/mode.rb', line 52

def raw_mode!
  @mode = :raw
end

#raw_mode?Boolean

Returns a boolean indicating whether the terminal is currently in ‘raw` mode.

Returns:

  • (Boolean)


45
46
47
# File 'lib/vedeu/terminal/mode.rb', line 45

def raw_mode?
  mode == :raw
end

#switch_mode!Symbol

Toggles the terminal’s mode between ‘cooked`, `fake` and `raw`, depending on its current mode.

Returns:

  • (Symbol)


60
61
62
63
64
65
# File 'lib/vedeu/terminal/mode.rb', line 60

def switch_mode!
  return fake_mode!   if raw_mode?
  return cooked_mode! if fake_mode?

  raw_mode!
end