Class: HandyToolbox::Cmd

Inherits:
Object
  • Object
show all
Defined in:
lib/handy_toolbox/cmd.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ Cmd

Returns a new instance of Cmd.



7
8
9
# File 'lib/handy_toolbox/cmd.rb', line 7

def initialize(cmd)
  @cmd = cmd
end

Instance Attribute Details

#outputObject (readonly)

Returns the value of attribute output.



5
6
7
# File 'lib/handy_toolbox/cmd.rb', line 5

def output
  @output
end

Class Method Details

.exec(cmd) ⇒ Object



11
12
13
# File 'lib/handy_toolbox/cmd.rb', line 11

def self.exec(cmd)
  Cmd.new(cmd).exec
end

Instance Method Details

#execObject



15
16
17
18
19
20
# File 'lib/handy_toolbox/cmd.rb', line 15

def exec
  @output = `#{@cmd} 2> /dev/null`.rstrip
  if ok?
    output
  end
end