Class: Session::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/session.rb,
lib/session-2.4.0.rb

Overview

class History

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ Command

–}}}



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/session.rb', line 69

def initialize(command)
#--{{{
  @cmd = command.to_s
  @cmdno = self.class.cmdno
  self.class.cmdno += 1
  @err = ''
  @out = ''
  @cid = "%d_%d_%d" % [$$, cmdno, rand(Time.now.usec)]
  @begin_out = "__CMD_OUT_%s_BEGIN__" % cid
  @end_out = "__CMD_OUT_%s_END__" % cid
  @begin_out_pat = %r/#{ Regexp.escape(@begin_out) }/
  @end_out_pat = %r/#{ Regexp.escape(@end_out) }/
  @begin_err = "__CMD_ERR_%s_BEGIN__" % cid
  @end_err = "__CMD_ERR_%s_END__" % cid
  @begin_err_pat = %r/#{ Regexp.escape(@begin_err) }/
  @end_err_pat = %r/#{ Regexp.escape(@end_err) }/
#--}}}
end

Instance Attribute Details

#begin_errObject (readonly)

Returns the value of attribute begin_err.



63
64
65
# File 'lib/session.rb', line 63

def begin_err
  @begin_err
end

#begin_err_patObject (readonly)

Returns the value of attribute begin_err_pat.



65
66
67
# File 'lib/session.rb', line 65

def begin_err_pat
  @begin_err_pat
end

#begin_outObject (readonly)

Returns the value of attribute begin_out.



59
60
61
# File 'lib/session.rb', line 59

def begin_out
  @begin_out
end

#begin_out_patObject (readonly)

Returns the value of attribute begin_out_pat.



61
62
63
# File 'lib/session.rb', line 61

def begin_out_pat
  @begin_out_pat
end

#cidObject (readonly)

Returns the value of attribute cid.



58
59
60
# File 'lib/session.rb', line 58

def cid
  @cid
end

#cmdObject (readonly)

–{{{



54
55
56
# File 'lib/session.rb', line 54

def cmd
  @cmd
end

#cmdnoObject (readonly)

Returns the value of attribute cmdno.



55
56
57
# File 'lib/session.rb', line 55

def cmdno
  @cmdno
end

#end_errObject (readonly)

Returns the value of attribute end_err.



64
65
66
# File 'lib/session.rb', line 64

def end_err
  @end_err
end

#end_err_patObject (readonly)

Returns the value of attribute end_err_pat.



66
67
68
# File 'lib/session.rb', line 66

def end_err_pat
  @end_err_pat
end

#end_outObject (readonly)

Returns the value of attribute end_out.



60
61
62
# File 'lib/session.rb', line 60

def end_out
  @end_out
end

#end_out_patObject (readonly)

Returns the value of attribute end_out_pat.



62
63
64
# File 'lib/session.rb', line 62

def end_out_pat
  @end_out_pat
end

#errObject

Returns the value of attribute err.



57
58
59
# File 'lib/session.rb', line 57

def err
  @err
end

#outObject

Returns the value of attribute out.



56
57
58
# File 'lib/session.rb', line 56

def out
  @out
end

Class Method Details

.cmdnoObject

–{{{



47
# File 'lib/session.rb', line 47

def cmdno; @cmdno ||= 0; end

.cmdno=(n) ⇒ Object



48
# File 'lib/session.rb', line 48

def cmdno= n; @cmdno = n; end

Instance Method Details

#to_hashObject

–}}}



87
88
89
90
91
# File 'lib/session.rb', line 87

def to_hash
#--{{{
  %w(cmdno cmd out err cid).inject({}){|h,k| h.update k => send(k) }
#--}}}
end

#to_yaml(*a, &b) ⇒ Object Also known as: to_s, to_str

–}}}



92
93
94
95
96
# File 'lib/session.rb', line 92

def to_yaml(*a,&b)
#--{{{
  to_hash.to_yaml(*a,&b)
#--}}}
end