Class: PrismChecker::ExpectationClassifier

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

Class Method Summary collapse

Class Method Details

.add(type, probe, position = 0) ⇒ Object


67
68
69
# File 'lib/prism_checker/expectation_classifier.rb', line 67

def self.add(type, probe, position = 0)
  @expectations_map.insert(position, [type, probe])
end

.array?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

51
52
53
# File 'lib/prism_checker/expectation_classifier.rb', line 51

def self.array?(expectation)
  expectation.is_a?(Array)
end

.boolean?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

59
60
61
# File 'lib/prism_checker/expectation_classifier.rb', line 59

def self.boolean?(expectation)
  expectation.is_a?(TrueClass) || expectation.is_a?(FalseClass)
end

.classify(expectation) ⇒ Object


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/prism_checker/expectation_classifier.rb', line 17

def self.classify(expectation)
  @expectations_map.each do |data|
    type = data[0]
    probe = data[1]
    if probe.is_a? Symbol
      return type if send(probe, expectation)
    elsif probe.call(expectation)
      return type
    end
  end

  :other
end

.empty?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/prism_checker/expectation_classifier.rb', line 39

def self.empty?(expectation)
  expectation == :empty
end

.hash?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

55
56
57
# File 'lib/prism_checker/expectation_classifier.rb', line 55

def self.hash?(expectation)
  expectation.is_a?(Hash)
end

.invisible?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
# File 'lib/prism_checker/expectation_classifier.rb', line 31

def self.invisible?(expectation)
  expectation == :invisible
end

.number?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

63
64
65
# File 'lib/prism_checker/expectation_classifier.rb', line 63

def self.number?(expectation)
  expectation.is_a?(Integer)
end

.regexp?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

47
48
49
# File 'lib/prism_checker/expectation_classifier.rb', line 47

def self.regexp?(expectation)
  expectation.is_a?(Regexp)
end

.string?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

43
44
45
# File 'lib/prism_checker/expectation_classifier.rb', line 43

def self.string?(expectation)
  expectation.is_a?(String)
end

.visible?(expectation) ⇒ Boolean

Returns:

  • (Boolean)

35
36
37
# File 'lib/prism_checker/expectation_classifier.rb', line 35

def self.visible?(expectation)
  expectation == :visible
end