Class: PrismChecker::ExpectationClassifier
- Inherits:
-
Object
- Object
- PrismChecker::ExpectationClassifier
- Defined in:
- lib/prism_checker/expectation_classifier.rb
Class Method Summary collapse
- .add(type, probe, position = 0) ⇒ Object
- .array?(expectation) ⇒ Boolean
- .boolean?(expectation) ⇒ Boolean
- .classify(expectation) ⇒ Object
- .empty?(expectation) ⇒ Boolean
- .hash?(expectation) ⇒ Boolean
- .invisible?(expectation) ⇒ Boolean
- .number?(expectation) ⇒ Boolean
- .regexp?(expectation) ⇒ Boolean
- .string?(expectation) ⇒ Boolean
- .visible?(expectation) ⇒ Boolean
Class Method Details
.add(type, probe, position = 0) ⇒ Object
66 67 68 |
# File 'lib/prism_checker/expectation_classifier.rb', line 66 def self.add(type, probe, position = 0) @expectations_map.insert(position, [type, probe]) end |
.array?(expectation) ⇒ Boolean
50 51 52 |
# File 'lib/prism_checker/expectation_classifier.rb', line 50 def self.array?(expectation) expectation.is_a?(Array) end |
.boolean?(expectation) ⇒ Boolean
58 59 60 |
# File 'lib/prism_checker/expectation_classifier.rb', line 58 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 |
# File 'lib/prism_checker/expectation_classifier.rb', line 17 def self.classify(expectation) @expectations_map.each do |data| type, probe = data if probe.is_a? Symbol return type if send(probe, expectation) elsif probe.call(expectation) return type end end :other end |
.empty?(expectation) ⇒ Boolean
38 39 40 |
# File 'lib/prism_checker/expectation_classifier.rb', line 38 def self.empty?(expectation) expectation == :empty end |
.hash?(expectation) ⇒ Boolean
54 55 56 |
# File 'lib/prism_checker/expectation_classifier.rb', line 54 def self.hash?(expectation) expectation.is_a?(Hash) end |
.invisible?(expectation) ⇒ Boolean
30 31 32 |
# File 'lib/prism_checker/expectation_classifier.rb', line 30 def self.invisible?(expectation) expectation == :invisible end |
.number?(expectation) ⇒ Boolean
62 63 64 |
# File 'lib/prism_checker/expectation_classifier.rb', line 62 def self.number?(expectation) expectation.is_a?(Integer) end |
.regexp?(expectation) ⇒ Boolean
46 47 48 |
# File 'lib/prism_checker/expectation_classifier.rb', line 46 def self.regexp?(expectation) expectation.is_a?(Regexp) end |
.string?(expectation) ⇒ Boolean
42 43 44 |
# File 'lib/prism_checker/expectation_classifier.rb', line 42 def self.string?(expectation) expectation.is_a?(String) end |
.visible?(expectation) ⇒ Boolean
34 35 36 |
# File 'lib/prism_checker/expectation_classifier.rb', line 34 def self.visible?(expectation) expectation == :visible end |