Class: Neovim::Executable
Overview
Object representing the ‘nvim` executable.
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_EXECUTABLE
environment variable.
Instance Method Summary collapse
-
#initialize(path) ⇒ Executable
constructor
A new instance of Executable.
-
#version ⇒ String
Fetch the
nvim
version.
Constructor Details
#initialize(path) ⇒ Executable
Returns a new instance of Executable.
19 20 21 |
# File 'lib/neovim/executable.rb', line 19 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
17 18 19 |
# File 'lib/neovim/executable.rb', line 17 def path @path end |
Class Method Details
.from_env(env = ENV) ⇒ Executable
Load the current executable from the NVIM_EXECUTABLE
environment variable.
13 14 15 |
# File 'lib/neovim/executable.rb', line 13 def self.from_env(env=ENV) new(env.fetch("NVIM_EXECUTABLE", "nvim")) end |
Instance Method Details
#version ⇒ String
Fetch the nvim
version.
26 27 28 29 30 31 32 |
# File 'lib/neovim/executable.rb', line 26 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 |