Class: Checkers::Run

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(printer) ⇒ Run

Returns a new instance of Run.



142
143
144
145
146
# File 'lib/checkers.rb', line 142

def initialize(printer)
  @failures = []
  @passes   = []
  @printer  = printer
end

Instance Attribute Details

#failuresObject (readonly)

Returns the value of attribute failures.



140
141
142
# File 'lib/checkers.rb', line 140

def failures
  @failures
end

#passesObject (readonly)

Returns the value of attribute passes.



140
141
142
# File 'lib/checkers.rb', line 140

def passes
  @passes
end

#printerObject (readonly)

Returns the value of attribute printer.



140
141
142
# File 'lib/checkers.rb', line 140

def printer
  @printer
end

Instance Method Details

#fail(check) ⇒ Object



153
154
155
156
# File 'lib/checkers.rb', line 153

def fail(check)
  failures << check
  printer.fail check
end

#failed?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/checkers.rb', line 158

def failed?
  !failures.empty?
end

#pass(check) ⇒ Object



148
149
150
151
# File 'lib/checkers.rb', line 148

def pass(check)
  passes << check
  printer.pass check
end

#statusObject



162
163
164
# File 'lib/checkers.rb', line 162

def status
  failed? ? 0 : 1
end

#summaryObject



166
167
168
# File 'lib/checkers.rb', line 166

def summary
  printer.summary passes, failures
end