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.
-
.become(klass, attributes) ⇒ Class
extended
from Common
private
Converts one class into another.
-
.boolean(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the value was a boolean.
-
.boolean?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Boolean.
-
.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.
-
.escape?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
.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.
-
.falsy?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value should be considered false.
-
.hash?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
.line_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
.mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`.
-
.numeric?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
.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(klass) ⇒ String
extended
from Common
private
Converts a class name to a lowercase snake case string.
-
.stream_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
.string?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
.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.
-
.truthy?(value) ⇒ Boolean
extended
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
.valid_mode?(mode) ⇒ Boolean
private
Returns a boolean indicating whether the given mode is valid.
- .valid_modes ⇒ Array<Symbol> private
-
.view_model? ⇒ Boolean
extended
from Common
private
Returns a boolean indicating the model is a Views::View.
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether a variable is nil or empty.
-
#become(klass, attributes) ⇒ Class
included
from Common
private
Converts one class into another.
-
#boolean(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating the value was a boolean.
-
#boolean?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Boolean.
-
#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.
-
#escape?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is an escape sequence object (e.g. Cells::Escape.).
-
#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.
-
#falsy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered false.
-
#hash?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Hash.
-
#line_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Line.
-
#mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`.
-
#numeric?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#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(klass) ⇒ String
included
from Common
private
Converts a class name to a lowercase snake case string.
-
#stream_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::Stream.
-
#string?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value is a Fixnum.
-
#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.
-
#truthy?(value) ⇒ Boolean
included
from Common
private
Returns a boolean indicating whether the value should be considered true.
-
#valid_mode?(mode) ⇒ Boolean
private
Returns a boolean indicating whether the given mode is valid.
- #valid_modes ⇒ Array<Symbol> private
-
#view_model? ⇒ Boolean
included
from Common
private
Returns a boolean indicating the model is a Views::View.
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.
.become(klass, attributes) ⇒ Class 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 one class into another.
.boolean(value) ⇒ 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 the value was a boolean.
.boolean?(value) ⇒ 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 the value is a Boolean.
.cooked_mode! ⇒ Symbol
Sets the terminal in to ‘cooked` mode.
25 26 27 |
# File 'lib/vedeu/terminal/mode.rb', line 25 def cooked_mode! switch_mode!(:cooked) end |
.cooked_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.
18 19 20 |
# File 'lib/vedeu/terminal/mode.rb', line 18 def cooked_mode? mode == :cooked end |
.escape?(value) ⇒ 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 the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
.fake_mode! ⇒ Symbol
Sets the terminal in to ‘fake` mode.
40 41 42 |
# File 'lib/vedeu/terminal/mode.rb', line 40 def fake_mode! switch_mode!(:fake) end |
.fake_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘fake` mode.
33 34 35 |
# File 'lib/vedeu/terminal/mode.rb', line 33 def fake_mode? mode == :fake end |
.falsy?(value) ⇒ 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 the value should be considered false.
.hash?(value) ⇒ 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 the value is a Hash.
.line_model? ⇒ 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 the model is a Views::Line.
.mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`. Can change throughout the lifespan of the client application.
83 84 85 |
# File 'lib/vedeu/terminal/mode.rb', line 83 def mode @mode = Vedeu.config.terminal_mode end |
.numeric?(value) ⇒ 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 the value is a Fixnum.
.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.
55 56 57 |
# File 'lib/vedeu/terminal/mode.rb', line 55 def raw_mode! switch_mode!(:raw) end |
.raw_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘raw` mode.
48 49 50 |
# File 'lib/vedeu/terminal/mode.rb', line 48 def raw_mode? mode == :raw end |
.snake_case(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.
Converts a class name to a lowercase snake case string.
.stream_model? ⇒ 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 the model is a Views::Stream.
.string?(value) ⇒ 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 the value is a Fixnum.
.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.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/vedeu/terminal/mode.rb', line 65 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 |
.truthy?(value) ⇒ 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 the value should be considered true.
.valid_mode?(mode) ⇒ Boolean (private)
Returns a boolean indicating whether the given mode is valid.
94 95 96 |
# File 'lib/vedeu/terminal/mode.rb', line 94 def valid_mode?(mode) valid_modes.include?(mode) end |
.valid_modes ⇒ Array<Symbol> (private)
99 100 101 102 103 104 105 |
# File 'lib/vedeu/terminal/mode.rb', line 99 def valid_modes [ :cooked, :fake, :raw, ] end |
.view_model? ⇒ 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 the model is a Views::View.
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.
#become(klass, attributes) ⇒ Class 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 one class into another.
#boolean(value) ⇒ 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 the value was a boolean.
#boolean?(value) ⇒ 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 the value is a Boolean.
#cooked_mode! ⇒ Symbol
Sets the terminal in to ‘cooked` mode.
25 26 27 |
# File 'lib/vedeu/terminal/mode.rb', line 25 def cooked_mode! switch_mode!(:cooked) end |
#cooked_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘cooked` mode.
18 19 20 |
# File 'lib/vedeu/terminal/mode.rb', line 18 def cooked_mode? mode == :cooked end |
#escape?(value) ⇒ 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 the value is an escape sequence object (e.g. Vedeu::Cells::Escape.)
#fake_mode! ⇒ Symbol
Sets the terminal in to ‘fake` mode.
40 41 42 |
# File 'lib/vedeu/terminal/mode.rb', line 40 def fake_mode! switch_mode!(:fake) end |
#fake_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘fake` mode.
33 34 35 |
# File 'lib/vedeu/terminal/mode.rb', line 33 def fake_mode? mode == :fake end |
#falsy?(value) ⇒ 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 the value should be considered false.
#hash?(value) ⇒ 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 the value is a Hash.
#line_model? ⇒ 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 the model is a Views::Line.
#mode ⇒ Symbol
Returns the mode of the terminal, either ‘:cooked`, `:fake` or `:raw`. Can change throughout the lifespan of the client application.
83 84 85 |
# File 'lib/vedeu/terminal/mode.rb', line 83 def mode @mode = Vedeu.config.terminal_mode end |
#numeric?(value) ⇒ 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 the value is a Fixnum.
#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.
55 56 57 |
# File 'lib/vedeu/terminal/mode.rb', line 55 def raw_mode! switch_mode!(:raw) end |
#raw_mode? ⇒ Boolean
Returns a boolean indicating whether the terminal is currently in ‘raw` mode.
48 49 50 |
# File 'lib/vedeu/terminal/mode.rb', line 48 def raw_mode? mode == :raw end |
#snake_case(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.
Converts a class name to a lowercase snake case string.
#stream_model? ⇒ 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 the model is a Views::Stream.
#string?(value) ⇒ 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 the value is a Fixnum.
#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.
65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/vedeu/terminal/mode.rb', line 65 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 |
#truthy?(value) ⇒ 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 the value should be considered true.
#valid_mode?(mode) ⇒ Boolean (private)
Returns a boolean indicating whether the given mode is valid.
94 95 96 |
# File 'lib/vedeu/terminal/mode.rb', line 94 def valid_mode?(mode) valid_modes.include?(mode) end |
#valid_modes ⇒ Array<Symbol> (private)
99 100 101 102 103 104 105 |
# File 'lib/vedeu/terminal/mode.rb', line 99 def valid_modes [ :cooked, :fake, :raw, ] end |
#view_model? ⇒ 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 the model is a Views::View.