Class: Ruby::Nginx::Commands::NginxVersion

Inherits:
TerminalCommand show all
Defined in:
lib/ruby/nginx/commands/nginx_version.rb

Instance Attribute Summary

Attributes inherited from TerminalCommand

#cmd, #error_type, #printer, #result, #user

Instance Method Summary collapse

Methods included from Helpers::SudoHelper

#sudoify

Methods included from Helpers::PromptHelper

#yes?

Constructor Details

#initializeNginxVersion

Returns a new instance of NginxVersion.



9
10
11
# File 'lib/ruby/nginx/commands/nginx_version.rb', line 9

def initialize
  super(cmd: "nginx -v", raise: Ruby::Nginx::Error)
end

Instance Method Details

#runObject



13
14
15
16
17
18
# File 'lib/ruby/nginx/commands/nginx_version.rb', line 13

def run
  super

  # nginx -v outputs to stderr
  Ruby::Nginx::Version.new(result.stderr.match(/\d+\.\d+\.?\d?/).to_s)
end