Class: Neovim::Executable
- Inherits:
-
Object
- Object
- Neovim::Executable
- Defined in:
- lib/neovim/executable.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- VERSION_PATTERN =
/\ANVIM v?(.+)$/
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
-
.from_env(env = ENV) ⇒ Executable
Load the current executable from the
NVIM_EXECUTABLEenvironment variable.
Instance Method Summary collapse
-
#initialize(path) ⇒ Executable
constructor
A new instance of Executable.
-
#version ⇒ String
Fetch the
nvimversion.
Constructor Details
#initialize(path) ⇒ Executable
Returns a new instance of Executable.
18 19 20 |
# File 'lib/neovim/executable.rb', line 18 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
16 17 18 |
# File 'lib/neovim/executable.rb', line 16 def path @path end |
Class Method Details
.from_env(env = ENV) ⇒ Executable
Load the current executable from the NVIM_EXECUTABLE environment variable.
12 13 14 |
# File 'lib/neovim/executable.rb', line 12 def self.from_env(env=ENV) new(env.fetch("NVIM_EXECUTABLE", "nvim")) end |
Instance Method Details
#version ⇒ String
Fetch the nvim version.
25 26 27 28 29 30 31 |
# File 'lib/neovim/executable.rb', line 25 def version @version ||= IO.popen([@path, "--version"]) do |io| io.gets[VERSION_PATTERN, 1] end rescue => e raise Error, "Couldn't load #{@path}: #{e}" end |