Class: Exemplor::Check

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

Defined Under Namespace

Classes: Failure

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, value) ⇒ Check



6
7
8
9
10
# File 'lib/checker.rb', line 6

def initialize(name, value)
  @name  = name
  @value = value
  @status = :info
end

Instance Attribute Details

#expectationObject (readonly)

Returns the value of attribute expectation.



4
5
6
# File 'lib/checker.rb', line 4

def expectation
  @expectation
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/checker.rb', line 4

def status
  @status
end

#valueObject (readonly)

Returns the value of attribute value.



4
5
6
# File 'lib/checker.rb', line 4

def value
  @value
end

Instance Method Details

#[](disambiguate) ⇒ Object



12
13
14
15
# File 'lib/checker.rb', line 12

def [](disambiguate)
  @disambiguate = disambiguate
  self
end

#failure?Boolean



34
35
36
# File 'lib/checker.rb', line 34

def failure?
  status == :failure
end

#info?Boolean



38
39
40
# File 'lib/checker.rb', line 38

def info?
  status == :info
end

#is(expectation) ⇒ Object

Raises:



24
25
26
27
28
# File 'lib/checker.rb', line 24

def is(expectation)
  @expectation = expectation
  @status = (value == expectation) ? :success : :failure
  raise Failure if failure?
end

#nameObject



17
18
19
# File 'lib/checker.rb', line 17

def name
  @name + (defined?(@disambiguate) ? " #{@disambiguate}" : '')
end

#success?Boolean



30
31
32
# File 'lib/checker.rb', line 30

def success?
  status == :success
end