Class: Rgot::Common
- Inherits:
-
Object
- Object
- Rgot::Common
- Defined in:
- lib/rgot/common.rb
Instance Attribute Summary collapse
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #error(*args) ⇒ Object
- #errorf(*args) ⇒ Object
- #fail! ⇒ Object
- #fail_now ⇒ Object
- #failed? ⇒ Boolean
- #fatal(*args) ⇒ Object
- #fatalf(*args) ⇒ Object
- #finish! ⇒ Object
- #finished? ⇒ Boolean
-
#initialize ⇒ Common
constructor
A new instance of Common.
- #log(*args) ⇒ Object
- #logf(*args) ⇒ Object
- #skip(*args) ⇒ Object
- #skip! ⇒ Object
- #skip_now ⇒ Object
- #skipf(*args) ⇒ Object
- #skipped? ⇒ Boolean
Constructor Details
#initialize ⇒ Common
Returns a new instance of Common.
7 8 9 10 11 12 13 14 |
# File 'lib/rgot/common.rb', line 7 def initialize @output = "" @failed = false @skipped = false @finished = false @start = Rgot.now @mutex = Mutex.new end |
Instance Attribute Details
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/rgot/common.rb', line 5 def output @output end |
Instance Method Details
#error(*args) ⇒ Object
50 51 52 53 54 |
# File 'lib/rgot/common.rb', line 50 def error(*args) internal_log(args.map(&:to_s).join(' ')) fail! nil end |
#errorf(*args) ⇒ Object
56 57 58 59 60 |
# File 'lib/rgot/common.rb', line 56 def errorf(*args) internal_log(sprintf(*args)) fail! nil end |
#fail! ⇒ Object
28 29 30 |
# File 'lib/rgot/common.rb', line 28 def fail! @mutex.synchronize { @failed = true } end |
#fail_now ⇒ Object
88 89 90 91 92 |
# File 'lib/rgot/common.rb', line 88 def fail_now fail! finish! throw :skip end |
#failed? ⇒ Boolean
16 17 18 |
# File 'lib/rgot/common.rb', line 16 def failed? @mutex.synchronize { @failed } end |
#fatal(*args) ⇒ Object
62 63 64 65 |
# File 'lib/rgot/common.rb', line 62 def fatal(*args) internal_log(args.map(&:to_s).join(' ')) fail_now end |
#fatalf(*args) ⇒ Object
67 68 69 70 |
# File 'lib/rgot/common.rb', line 67 def fatalf(*args) internal_log(sprintf(*args)) fail_now end |
#finish! ⇒ Object
36 37 38 |
# File 'lib/rgot/common.rb', line 36 def finish! @mutex.synchronize { @finished = true } end |
#finished? ⇒ Boolean
24 25 26 |
# File 'lib/rgot/common.rb', line 24 def finished? @mutex.synchronize { @finished } end |
#log(*args) ⇒ Object
40 41 42 43 |
# File 'lib/rgot/common.rb', line 40 def log(*args) internal_log(args.map(&:to_s).join(' ')) nil end |
#logf(*args) ⇒ Object
45 46 47 48 |
# File 'lib/rgot/common.rb', line 45 def logf(*args) internal_log(sprintf(*args)) nil end |
#skip(*args) ⇒ Object
72 73 74 75 |
# File 'lib/rgot/common.rb', line 72 def skip(*args) internal_log(args.map(&:to_s).join(' ')) skip_now end |
#skip! ⇒ Object
32 33 34 |
# File 'lib/rgot/common.rb', line 32 def skip! @mutex.synchronize { @skipped = true } end |
#skip_now ⇒ Object
82 83 84 85 86 |
# File 'lib/rgot/common.rb', line 82 def skip_now skip! finish! throw :skip end |
#skipf(*args) ⇒ Object
77 78 79 80 |
# File 'lib/rgot/common.rb', line 77 def skipf(*args) internal_log(sprintf(*args)) skip_now end |
#skipped? ⇒ Boolean
20 21 22 |
# File 'lib/rgot/common.rb', line 20 def skipped? @mutex.synchronize { @skipped } end |