Class: Lucie::Commands::CommandsHelper
- Inherits:
-
Object
- Object
- Lucie::Commands::CommandsHelper
- Defined in:
- lib/lucie-cmd/commands.rb
Instance Attribute Summary collapse
-
#pwd ⇒ Object
Returns the value of attribute pwd.
Instance Method Summary collapse
-
#initialize ⇒ CommandsHelper
constructor
A new instance of CommandsHelper.
- #output ⇒ Object
- #sh(*args) ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize ⇒ CommandsHelper
31 32 33 34 |
# File 'lib/lucie-cmd/commands.rb', line 31 def initialize @stderr = $stderr @pwd = Dir.pwd end |
Instance Attribute Details
#pwd ⇒ Object
Returns the value of attribute pwd.
29 30 31 |
# File 'lib/lucie-cmd/commands.rb', line 29 def pwd @pwd end |
Instance Method Details
#output ⇒ Object
42 43 44 |
# File 'lib/lucie-cmd/commands.rb', line 42 def output @stdout.read end |
#sh(*args) ⇒ Object
36 37 38 39 40 |
# File 'lib/lucie-cmd/commands.rb', line 36 def sh(*args) command = args.join(" ") @pid, @stdin, @stdout, @stderr = Open4::popen4("cd \"#{pwd}\" && #{command}") @ignored, @status = Process::waitpid2 @pid end |
#status ⇒ Object
46 47 48 |
# File 'lib/lucie-cmd/commands.rb', line 46 def status @status.to_i % 255 end |