Class: Godo::Session
- Inherits:
-
Object
show all
- Defined in:
- lib/session.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path) ⇒ Session
Returns a new instance of Session.
6
7
8
9
|
# File 'lib/session.rb', line 6
def initialize( path )
@path = path
@counters = Hash.new { 0 }
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
4
5
6
|
# File 'lib/session.rb', line 4
def path
@path
end
|
Instance Method Details
#counter(name) ⇒ Object
43
44
45
46
|
# File 'lib/session.rb', line 43
def counter( name )
@counters[name] += 1
"#{@counters[name]}"
end
|
#create(label, command, exit) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/session.rb', line 11
def create( label, command, exit )
start
set_label( label )
execute( "cd #{path}; clear;" )
if command
command = eval( "\"" + command + "\"", get_binding )
execute( command )
end
if exit
execute( "sleep 5; exit" )
end
end
|
#execute(command) ⇒ Object
39
40
41
|
# File 'lib/session.rb', line 39
def execute( command )
raise "#{self.class.name} must implement #execute"
end
|
#set_label(label) ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'lib/session.rb', line 26
def set_label( label )
if label
label = eval( "\"" + label + "\"" )
execute( "echo -n -e \"\\033]0;#{label}\\007\"; clear;" )
else
execute( "clear;" )
end
end
|
#start ⇒ Object
35
36
37
|
# File 'lib/session.rb', line 35
def start
raise "#{self.class.name} must implement #start"
end
|