Class: Session::Command
- Inherits:
-
Object
- Object
- Session::Command
- Defined in:
- lib/session.rb
Overview
class History
Instance Attribute Summary collapse
-
#begin_err ⇒ Object
readonly
Returns the value of attribute begin_err.
-
#begin_err_pat ⇒ Object
readonly
Returns the value of attribute begin_err_pat.
-
#begin_out ⇒ Object
readonly
Returns the value of attribute begin_out.
-
#begin_out_pat ⇒ Object
readonly
Returns the value of attribute begin_out_pat.
-
#cid ⇒ Object
readonly
Returns the value of attribute cid.
-
#cmd ⇒ Object
readonly
attributes.
-
#cmdno ⇒ Object
readonly
Returns the value of attribute cmdno.
-
#end_err ⇒ Object
readonly
Returns the value of attribute end_err.
-
#end_err_pat ⇒ Object
readonly
Returns the value of attribute end_err_pat.
-
#end_out ⇒ Object
readonly
Returns the value of attribute end_out.
-
#end_out_pat ⇒ Object
readonly
Returns the value of attribute end_out_pat.
-
#err ⇒ Object
Returns the value of attribute err.
-
#out ⇒ Object
Returns the value of attribute out.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(command) ⇒ Command
constructor
A new instance of Command.
- #to_hash ⇒ Object
- #to_yaml(*a, &b) ⇒ Object (also: #to_s, #to_str)
Constructor Details
#initialize(command) ⇒ Command
Returns a new instance of Command.
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/session.rb', line 62 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_err ⇒ Object (readonly)
Returns the value of attribute begin_err.
57 58 59 |
# File 'lib/session.rb', line 57 def begin_err @begin_err end |
#begin_err_pat ⇒ Object (readonly)
Returns the value of attribute begin_err_pat.
59 60 61 |
# File 'lib/session.rb', line 59 def begin_err_pat @begin_err_pat end |
#begin_out ⇒ Object (readonly)
Returns the value of attribute begin_out.
53 54 55 |
# File 'lib/session.rb', line 53 def begin_out @begin_out end |
#begin_out_pat ⇒ Object (readonly)
Returns the value of attribute begin_out_pat.
55 56 57 |
# File 'lib/session.rb', line 55 def begin_out_pat @begin_out_pat end |
#cid ⇒ Object (readonly)
Returns the value of attribute cid.
52 53 54 |
# File 'lib/session.rb', line 52 def cid @cid end |
#cmd ⇒ Object (readonly)
attributes
48 49 50 |
# File 'lib/session.rb', line 48 def cmd @cmd end |
#cmdno ⇒ Object (readonly)
Returns the value of attribute cmdno.
49 50 51 |
# File 'lib/session.rb', line 49 def cmdno @cmdno end |
#end_err ⇒ Object (readonly)
Returns the value of attribute end_err.
58 59 60 |
# File 'lib/session.rb', line 58 def end_err @end_err end |
#end_err_pat ⇒ Object (readonly)
Returns the value of attribute end_err_pat.
60 61 62 |
# File 'lib/session.rb', line 60 def end_err_pat @end_err_pat end |
#end_out ⇒ Object (readonly)
Returns the value of attribute end_out.
54 55 56 |
# File 'lib/session.rb', line 54 def end_out @end_out end |
#end_out_pat ⇒ Object (readonly)
Returns the value of attribute end_out_pat.
56 57 58 |
# File 'lib/session.rb', line 56 def end_out_pat @end_out_pat end |
#err ⇒ Object
Returns the value of attribute err.
51 52 53 |
# File 'lib/session.rb', line 51 def err @err end |
#out ⇒ Object
Returns the value of attribute out.
50 51 52 |
# File 'lib/session.rb', line 50 def out @out end |
Class Method Details
.cmdno ⇒ Object
43 |
# File 'lib/session.rb', line 43 def cmdno; @cmdno ||= 0; end |
.cmdno=(n) ⇒ Object
44 |
# File 'lib/session.rb', line 44 def cmdno= n; @cmdno = n; end |
Instance Method Details
#to_hash ⇒ Object
78 79 80 |
# File 'lib/session.rb', line 78 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
81 82 83 |
# File 'lib/session.rb', line 81 def to_yaml(*a,&b) to_hash.to_yaml(*a,&b) end |