Module: Vedeu::Terminal::Mode
- Extended by:
- Mode
- Includes:
- Common
- Included in:
- Vedeu::Terminal, Mode
- Defined in:
- lib/vedeu/terminal/mode.rb
Overview
Store the current mode of the terminal.
Class Method Summary collapse
-
.absent?(variable) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
.cooked_mode! ⇒ Symbol
Sets the terminal in to ‘cooked` mode.
-
.cooked_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.
-
.demodulize(klass) ⇒ String
extended
from Common
private
Removes the module part from the expression in the string.
-
.fake_mode! ⇒ Symbol
Sets the terminal in to ‘fake` mode.
-
.fake_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘fake` mode.
-
.mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`.
-
.present?(variable) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
.raw_mode! ⇒ Symbol
Sets the terminal in to ‘raw` mode.
-
.raw_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘raw` mode.
-
.snake_case(name) ⇒ String
extended
from Common
private
Converts a class name to a lowercase snake case string.
-
.switch_mode!(mode = nil) ⇒ Symbol
Changes the mode of the terminal to the mode given or toggles the terminal mode between ‘cooked`, `fake` and `raw`, depending on the current mode.
-
.valid_mode?(mode) ⇒ Boolean
private
Returns a boolean indicating whether the given mode is valid.
- .valid_modes ⇒ Array<Symbol> private
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#cooked_mode! ⇒ Symbol
Sets the terminal in to ‘cooked` mode.
-
#cooked_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.
-
#demodulize(klass) ⇒ String
included
from Common
private
Removes the module part from the expression in the string.
-
#fake_mode! ⇒ Symbol
Sets the terminal in to ‘fake` mode.
-
#fake_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘fake` mode.
-
#mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`.
-
#present?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable has a useful value.
-
#raw_mode! ⇒ Symbol
Sets the terminal in to ‘raw` mode.
-
#raw_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘raw` mode.
-
#snake_case(name) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#switch_mode!(mode = nil) ⇒ Symbol
Changes the mode of the terminal to the mode given or toggles the terminal mode between ‘cooked`, `fake` and `raw`, depending on the current mode.
-
#valid_mode?(mode) ⇒ Boolean
private
Returns a boolean indicating whether the given mode is valid.
- #valid_modes ⇒ Array<Symbol> private
Class Method Details
.absent?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
.cooked_mode! ⇒ Symbol
Sets the terminal in to ‘cooked` mode.
23 24 25 |
# File 'lib/vedeu/terminal/mode.rb', line 23 def cooked_mode! switch_mode!(:cooked) end |
.cooked_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.
16 17 18 |
# File 'lib/vedeu/terminal/mode.rb', line 16 def cooked_mode? mode == :cooked end |
.demodulize(klass) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes the module part from the expression in the string.
.fake_mode! ⇒ Symbol
Sets the terminal in to ‘fake` mode.
38 39 40 |
# File 'lib/vedeu/terminal/mode.rb', line 38 def fake_mode! switch_mode!(:fake) end |
.fake_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘fake` mode.
31 32 33 |
# File 'lib/vedeu/terminal/mode.rb', line 31 def fake_mode? mode == :fake end |
.mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`. Can change throughout the lifespan of the client application.
81 82 83 |
# File 'lib/vedeu/terminal/mode.rb', line 81 def mode @mode = Vedeu::Configuration.terminal_mode end |
.present?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
.raw_mode! ⇒ Symbol
Sets the terminal in to ‘raw` mode.
53 54 55 |
# File 'lib/vedeu/terminal/mode.rb', line 53 def raw_mode! switch_mode!(:raw) end |
.raw_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘raw` mode.
46 47 48 |
# File 'lib/vedeu/terminal/mode.rb', line 46 def raw_mode? mode == :raw end |
.snake_case(name) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
.switch_mode!(mode = nil) ⇒ Symbol
Changes the mode of the terminal to the mode given or toggles the terminal mode between ‘cooked`, `fake` and `raw`, depending on the current mode.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vedeu/terminal/mode.rb', line 63 def switch_mode!(mode = nil) if present?(mode) && valid_mode?(mode) Vedeu.configure { |config| config.terminal_mode = mode } else return fake_mode! if raw_mode? return cooked_mode! if fake_mode? raw_mode! end end |
.valid_mode?(mode) ⇒ Boolean (private)
Returns a boolean indicating whether the given mode is valid.
92 93 94 |
# File 'lib/vedeu/terminal/mode.rb', line 92 def valid_mode?(mode) valid_modes.include?(mode) end |
.valid_modes ⇒ Array<Symbol> (private)
97 98 99 100 101 102 103 |
# File 'lib/vedeu/terminal/mode.rb', line 97 def valid_modes [ :cooked, :fake, :raw, ] end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable is nil or empty.
#cooked_mode! ⇒ Symbol
Sets the terminal in to ‘cooked` mode.
23 24 25 |
# File 'lib/vedeu/terminal/mode.rb', line 23 def cooked_mode! switch_mode!(:cooked) end |
#cooked_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.
16 17 18 |
# File 'lib/vedeu/terminal/mode.rb', line 16 def cooked_mode? mode == :cooked end |
#demodulize(klass) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Removes the module part from the expression in the string.
#fake_mode! ⇒ Symbol
Sets the terminal in to ‘fake` mode.
38 39 40 |
# File 'lib/vedeu/terminal/mode.rb', line 38 def fake_mode! switch_mode!(:fake) end |
#fake_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘fake` mode.
31 32 33 |
# File 'lib/vedeu/terminal/mode.rb', line 31 def fake_mode? mode == :fake end |
#mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`. Can change throughout the lifespan of the client application.
81 82 83 |
# File 'lib/vedeu/terminal/mode.rb', line 81 def mode @mode = Vedeu::Configuration.terminal_mode end |
#present?(variable) ⇒ Boolean Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a boolean indicating whether a variable has a useful value.
#raw_mode! ⇒ Symbol
Sets the terminal in to ‘raw` mode.
53 54 55 |
# File 'lib/vedeu/terminal/mode.rb', line 53 def raw_mode! switch_mode!(:raw) end |
#raw_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘raw` mode.
46 47 48 |
# File 'lib/vedeu/terminal/mode.rb', line 46 def raw_mode? mode == :raw end |
#snake_case(name) ⇒ String Originally defined in module Common
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Converts a class name to a lowercase snake case string.
#switch_mode!(mode = nil) ⇒ Symbol
Changes the mode of the terminal to the mode given or toggles the terminal mode between ‘cooked`, `fake` and `raw`, depending on the current mode.
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/vedeu/terminal/mode.rb', line 63 def switch_mode!(mode = nil) if present?(mode) && valid_mode?(mode) Vedeu.configure { |config| config.terminal_mode = mode } else return fake_mode! if raw_mode? return cooked_mode! if fake_mode? raw_mode! end end |
#valid_mode?(mode) ⇒ Boolean (private)
Returns a boolean indicating whether the given mode is valid.
92 93 94 |
# File 'lib/vedeu/terminal/mode.rb', line 92 def valid_mode?(mode) valid_modes.include?(mode) end |
#valid_modes ⇒ Array<Symbol> (private)
97 98 99 100 101 102 103 |
# File 'lib/vedeu/terminal/mode.rb', line 97 def valid_modes [ :cooked, :fake, :raw, ] end |