Class: Expect::Result
- Inherits:
-
Struct
- Object
- Struct
- Expect::Result
- Defined in:
- lib/expect/result.rb
Overview
保存一次等待的结果,保留 Struct 原生数组、Hash 转换和模式解构能力。 number 仅在文本匹配时存在;error 为 :timeout、:eof 或原始 IO 异常,文本字段均为字节串。 before/match/after 是产生结果时的快照,后续读取不追加到旧结果;captures 保留未参与捕获的 nil。 结果对象仍采用普通可变 Struct 语义;session 只引用来源,不取得 IO 或子进程所有权。
Instance Attribute Summary collapse
-
#after ⇒ Object
Returns the value of attribute after.
-
#before ⇒ Object
Returns the value of attribute before.
-
#captures ⇒ Object
Returns the value of attribute captures.
-
#error ⇒ Object
Returns the value of attribute error.
-
#match ⇒ Object
Returns the value of attribute match.
-
#number ⇒ Object
Returns the value of attribute number.
-
#session ⇒ Object
Returns the value of attribute session.
Instance Method Summary collapse
-
#eof? ⇒ Boolean
是否读取源已经结束;子进程是否退出仍应查询会话的 process_status。.
-
#matched? ⇒ Boolean
是否命中文本模式;事件不会返回模式序号。.
-
#timeout? ⇒ Boolean
是否因本次等待期限到达而返回。.
Instance Attribute Details
#after ⇒ Object
Returns the value of attribute after
8 9 10 |
# File 'lib/expect/result.rb', line 8 def after @after end |
#before ⇒ Object
Returns the value of attribute before
8 9 10 |
# File 'lib/expect/result.rb', line 8 def before @before end |
#captures ⇒ Object
Returns the value of attribute captures
8 9 10 |
# File 'lib/expect/result.rb', line 8 def captures @captures end |
#error ⇒ Object
Returns the value of attribute error
8 9 10 |
# File 'lib/expect/result.rb', line 8 def error @error end |
#match ⇒ Object
Returns the value of attribute match
8 9 10 |
# File 'lib/expect/result.rb', line 8 def match @match end |
#number ⇒ Object
Returns the value of attribute number
8 9 10 |
# File 'lib/expect/result.rb', line 8 def number @number end |
#session ⇒ Object
Returns the value of attribute session
8 9 10 |
# File 'lib/expect/result.rb', line 8 def session @session end |
Instance Method Details
#eof? ⇒ Boolean
是否读取源已经结束;子进程是否退出仍应查询会话的 process_status。
16 |
# File 'lib/expect/result.rb', line 16 def eof? = error == :eof |
#matched? ⇒ Boolean
是否命中文本模式;事件不会返回模式序号。
10 |
# File 'lib/expect/result.rb', line 10 def matched? = !number.nil? |
#timeout? ⇒ Boolean
是否因本次等待期限到达而返回。
13 |
# File 'lib/expect/result.rb', line 13 def timeout? = error == :timeout |