Class: Rgot::Common

Inherits:
Object
  • Object
show all
Defined in:
lib/rgot/common.rb

Direct Known Subclasses

B, F, T

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommon

Returns a new instance of Common.



11
12
13
14
15
16
17
18
# File 'lib/rgot/common.rb', line 11

def initialize
  @output = "".dup
  @failed = false
  @skipped = false
  @finished = false
  @start = Rgot.now
  @mutex = Thread::Mutex.new
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



9
10
11
# File 'lib/rgot/common.rb', line 9

def output
  @output
end

Instance Method Details

#error(*args) ⇒ Object



54
55
56
57
58
# File 'lib/rgot/common.rb', line 54

def error(*args)
  internal_log(args.map(&:to_s).join(' '))
  fail!
  nil
end

#errorf(*args) ⇒ Object



60
61
62
63
64
# File 'lib/rgot/common.rb', line 60

def errorf(*args)
  internal_log(sprintf(*args))
  fail!
  nil
end

#fail!Object



32
33
34
# File 'lib/rgot/common.rb', line 32

def fail!
  @mutex.synchronize { @failed = true }
end

#fail_nowObject



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

def fail_now
  fail!
  finish!
  throw :skip
end

#failed?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rgot/common.rb', line 20

def failed?
  @mutex.synchronize { @failed }
end

#fatal(*args) ⇒ Object



66
67
68
69
# File 'lib/rgot/common.rb', line 66

def fatal(*args)
  internal_log(args.map(&:to_s).join(' '))
  fail_now
end

#fatalf(*args) ⇒ Object



71
72
73
74
# File 'lib/rgot/common.rb', line 71

def fatalf(*args)
  internal_log(sprintf(*args))
  fail_now
end

#finish!Object



40
41
42
# File 'lib/rgot/common.rb', line 40

def finish!
  @mutex.synchronize { @finished = true }
end

#finished?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/rgot/common.rb', line 28

def finished?
  @mutex.synchronize { @finished }
end

#log(*args) ⇒ Object



44
45
46
47
# File 'lib/rgot/common.rb', line 44

def log(*args)
  internal_log(args.map(&:to_s).join(' '))
  nil
end

#logf(*args) ⇒ Object



49
50
51
52
# File 'lib/rgot/common.rb', line 49

def logf(*args)
  internal_log(sprintf(*args))
  nil
end

#skip(*args) ⇒ Object



76
77
78
79
# File 'lib/rgot/common.rb', line 76

def skip(*args)
  internal_log(args.map(&:to_s).join(' '))
  skip_now
end

#skip!Object



36
37
38
# File 'lib/rgot/common.rb', line 36

def skip!
  @mutex.synchronize { @skipped = true }
end

#skip_nowObject



86
87
88
89
90
# File 'lib/rgot/common.rb', line 86

def skip_now
  skip!
  finish!
  throw :skip
end

#skipf(*args) ⇒ Object



81
82
83
84
# File 'lib/rgot/common.rb', line 81

def skipf(*args)
  internal_log(sprintf(*args))
  skip_now
end

#skipped?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/rgot/common.rb', line 24

def skipped?
  @mutex.synchronize { @skipped }
end