Class: Transfuse::Cmd

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ Cmd

Returns a new instance of Cmd.



15
16
17
# File 'lib/transfuse/cmd.rb', line 15

def initialize cmd
  @cmd = cmd
end

Instance Attribute Details

#cmdObject

Returns the value of attribute cmd.



13
14
15
# File 'lib/transfuse/cmd.rb', line 13

def cmd
  @cmd
end

#statusObject

Returns the value of attribute status.



13
14
15
# File 'lib/transfuse/cmd.rb', line 13

def status
  @status
end

#stderrObject

Returns the value of attribute stderr.



13
14
15
# File 'lib/transfuse/cmd.rb', line 13

def stderr
  @stderr
end

#stdoutObject

Returns the value of attribute stdout.



13
14
15
# File 'lib/transfuse/cmd.rb', line 13

def stdout
  @stdout
end

Instance Method Details

#run(file = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/transfuse/cmd.rb', line 19

def run file=nil
  unless file.nil?
    if File.exist?(file) and File.stat(file).size > 0
      @stdout = ""
      @stderr = ""
      @status = Status.new
      return true
    end
  end
  @stdout, @stderr, @status = Open3.capture3 @cmd
  return false
end

#to_sObject



32
33
34
# File 'lib/transfuse/cmd.rb', line 32

def to_s
  @cmd
end