Class: Vedeu::Editor::Editor
- Inherits:
-
Object
- Object
- Vedeu::Editor::Editor
- Extended by:
- Forwardable
- Includes:
- Common
- Defined in:
- lib/vedeu/editor/editor.rb
Overview
Handles keypresses for a named document whilst the terminal is in fake mode.
Instance Attribute Summary collapse
- #input ⇒ Symbol|String readonly protected
- #name ⇒ String readonly protected
Class Method Summary collapse
-
.keypress(input:, name:) ⇒ String|Symbol
Send given input to the named document.
Instance Method Summary collapse
-
#absent?(variable) ⇒ Boolean
included
from Common
Returns a boolean indicating whether a variable is nil or empty.
-
#demodulize(klass) ⇒ String
included
from Common
Removes the module part from the expression in the string.
-
#document ⇒ Vedeu::Editor::Document
private
Return the document by name from the documents repository.
-
#initialize(input:, name:) ⇒ Vedeu::Editor::Editor
constructor
Returns a new instance of Vedeu::Editor::Editor.
-
#keypress ⇒ String|Symbol
Send given input to the named document.
-
#present?(variable) ⇒ Boolean
included
from Common
Returns a boolean indicating whether a variable has a useful value.
-
#snake_case(name) ⇒ String
included
from Common
Converts a class name to a lowercase snake case string.
Constructor Details
#initialize(input:, name:) ⇒ Vedeu::Editor::Editor
Returns a new instance of Vedeu::Editor::Editor.
40 41 42 43 |
# File 'lib/vedeu/editor/editor.rb', line 40 def initialize(input:, name:) @input = input @name = name end |
Instance Attribute Details
#input ⇒ Symbol|String (readonly, protected)
71 72 73 |
# File 'lib/vedeu/editor/editor.rb', line 71 def input @input end |
#name ⇒ String (readonly, protected)
75 76 77 |
# File 'lib/vedeu/editor/editor.rb', line 75 def name @name end |
Class Method Details
.keypress(input:, name:) ⇒ String|Symbol
Send given input to the named document.
31 32 33 |
# File 'lib/vedeu/editor/editor.rb', line 31 def self.keypress(input:, name:) new(input: input, name: name).keypress end |
Instance Method Details
#absent?(variable) ⇒ Boolean Originally defined in module Common
Returns a boolean indicating whether a variable is nil or empty.
#demodulize(klass) ⇒ String Originally defined in module Common
Removes the module part from the expression in the string.
#document ⇒ Vedeu::Editor::Document (private)
Return the document by name from the documents repository.
82 83 84 |
# File 'lib/vedeu/editor/editor.rb', line 82 def document @document ||= Vedeu.documents.by_name(name) end |
#keypress ⇒ String|Symbol
Send given input to the named document.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vedeu/editor/editor.rb', line 48 def keypress return input unless document case input when :backspace then delete_character when :delete then delete_line when :ctrl_c then Vedeu.trigger(:_exit_) when :down then down when :enter then insert_line when :escape then Vedeu.trigger(:_mode_switch_) when :left then left when :right then right when :tab then execute when :up then up else insert_character(input) end end |
#present?(variable) ⇒ Boolean Originally defined in module Common
Returns a boolean indicating whether a variable has a useful value.
#snake_case(name) ⇒ String Originally defined in module Common
Converts a class name to a lowercase snake case string.