Class: AIA::Editor
Constant Summary collapse
- DEFAULT_PARAMETERS =
""
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
Instance Method Summary collapse
- #build_command ⇒ Object
- #discover_editor ⇒ Object
-
#initialize(file: "") ⇒ Editor
constructor
A new instance of Editor.
- #run ⇒ Object
Methods inherited from Tools
catalog, get_meta, inherited, load_tools, #meta, meta, search_for, setup_backend, validate_tools
Constructor Details
#initialize(file: "") ⇒ Editor
Returns a new instance of Editor.
21 22 23 24 25 26 27 |
# File 'lib/aia/tools/editor.rb', line 21 def initialize(file: "") @file = file discover_editor build_command end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
18 19 20 |
# File 'lib/aia/tools/editor.rb', line 18 def command @command end |
Instance Method Details
#build_command ⇒ Object
43 44 45 |
# File 'lib/aia/tools/editor.rb', line 43 def build_command @command = "#{.name} #{DEFAULT_PARAMETERS} #{@file}" end |
#discover_editor ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/aia/tools/editor.rb', line 30 def discover_editor editor = ENV['EDITOR'] # This might be nil if editor.nil? @name = "echo" @description = "You have no default editor" @install = "Set your system environment variable EDITOR" else @name = editor end end |
#run ⇒ Object
48 49 50 |
# File 'lib/aia/tools/editor.rb', line 48 def run `#{command}` end |