Class: EditorCommand
- Inherits:
-
Object
- Object
- EditorCommand
- Defined in:
- lib/vimput/editor_command.rb
Constant Summary collapse
- EDITOR_COMMANDS =
{ atom: 'atom --wait', emacs: 'emacs', macvim: 'mvim -f', sublime_text: 'subl -n -w', vim: 'vim' }
Instance Method Summary collapse
-
#initialize(editor: nil, command: nil) ⇒ EditorCommand
constructor
A new instance of EditorCommand.
- #text ⇒ Object
Constructor Details
#initialize(editor: nil, command: nil) ⇒ EditorCommand
Returns a new instance of EditorCommand.
10 11 12 13 14 15 16 17 |
# File 'lib/vimput/editor_command.rb', line 10 def initialize(editor: nil, command: nil) if editor && command raise ArgumentError.new('Pass only an editor or a command to Vimput, not both.') end @editor = editor&.to_sym @command = command end |
Instance Method Details
#text ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/vimput/editor_command.rb', line 19 def text if command = EDITOR_COMMANDS[@editor] command elsif @command @command else ENV["VISUAL"] || ENV["EDITOR"] || "vim" end end |