Class: AIA::Editor

Inherits:
Tools
  • Object
show all
Defined in:
lib/aia/tools/editor.rb

Constant Summary collapse

DEFAULT_PARAMETERS =
""

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#commandObject

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_commandObject



43
44
45
# File 'lib/aia/tools/editor.rb', line 43

def build_command
  @command = "#{meta.name} #{DEFAULT_PARAMETERS} #{@file}"
end

#discover_editorObject



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

#runObject



48
49
50
# File 'lib/aia/tools/editor.rb', line 48

def run
  `#{command}`
end