Module: Space::Shell
Defined Under Namespace
Modules: ClassMethods, Watcher
Classes: Command, Watch
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Watcher
suspend, suspended?
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
33
34
35
|
# File 'lib/space/shell.rb', line 33
def path
@path
end
|
Class Method Details
.all ⇒ Object
24
25
26
|
# File 'lib/space/shell.rb', line 24
def all
@all ||= []
end
|
.included(base) ⇒ Object
20
21
22
|
# File 'lib/space/shell.rb', line 20
def included(base)
base.extend(ClassMethods)
end
|
.refresh ⇒ Object
28
29
30
|
# File 'lib/space/shell.rb', line 28
def refresh
all.map(&:refresh)
end
|
Instance Method Details
#commands ⇒ Object
45
46
47
48
49
|
# File 'lib/space/shell.rb', line 45
def commands
@commands ||= self.class.commands.inject({}) do |commands, (key, command)|
commands.merge(key => Command.new(self, command))
end
end
|
#initialize(path = '.') ⇒ Object
35
36
37
38
39
|
# File 'lib/space/shell.rb', line 35
def initialize(path = '.')
@path = File.expand_path(path)
Shell.all << self
super
end
|
#refresh ⇒ Object
51
52
53
54
|
# File 'lib/space/shell.rb', line 51
def refresh
commands.each { |key, command| command.run }
end
|
#result(command) ⇒ Object
41
42
43
|
# File 'lib/space/shell.rb', line 41
def result(command)
commands[command].result
end
|