Class: Xcode::Shell::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/xcode/shell/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd, environment = {}) ⇒ Command

Returns a new instance of Command.



8
9
10
11
12
# File 'lib/xcode/shell/command.rb', line 8

def initialize(cmd, environment={})
  @cmd = cmd
  @args = []
  @env = environment
end

Instance Attribute Details

#envObject

Returns the value of attribute env.



6
7
8
# File 'lib/xcode/shell/command.rb', line 6

def env
  @env
end

Instance Method Details

#<<(arg) ⇒ Object



14
15
16
# File 'lib/xcode/shell/command.rb', line 14

def <<(arg)
  @args << arg
end

#==(obj) ⇒ Object



30
31
32
33
34
# File 'lib/xcode/shell/command.rb', line 30

def ==(obj)
  return false unless obj.is_a? Xcode::Shell::Command
  # to_s==obj.to_s
  Set.new(obj.to_a) == Set.new(self.to_a)
end

#execute(show_output = true, &block) ⇒ Object

:yield: output



36
37
38
# File 'lib/xcode/shell/command.rb', line 36

def execute(show_output=true, &block) #:yield: output
  Xcode::Shell.execute(self, show_output, &block)
end

#to_aObject



22
23
24
25
26
27
28
# File 'lib/xcode/shell/command.rb', line 22

def to_a
  out = []
  out << @cmd
  out+=@args
  out+=(@env.map {|k,v| "#{k}=#{v}"})
  out
end

#to_sObject



18
19
20
# File 'lib/xcode/shell/command.rb', line 18

def to_s
  "#{to_a.join(' ')}"
end