Class: PrismChecker::ExpectationClassifier
- Inherits:
-
Object
- Object
- PrismChecker::ExpectationClassifier
- Defined in:
- lib/prism_checker/expectation_classifier.rb
Constant Summary collapse
- EXPECTATIONS_MAP =
[ %i[invisible invisible?], %i[visible visible?], %i[empty empty?], %i[string string?], %i[regexp regexp?], %i[array array?], %i[hash hash?], %i[boolean boolean?], %i[number number?] ].freeze
Class Method Summary collapse
- .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
.array?(expectation) ⇒ Boolean
46 47 48 |
# File 'lib/prism_checker/expectation_classifier.rb', line 46 def self.array?(expectation) expectation.is_a?(Array) end |
.boolean?(expectation) ⇒ Boolean
54 55 56 |
# File 'lib/prism_checker/expectation_classifier.rb', line 54 def self.boolean?(expectation) expectation.is_a?(TrueClass) || expectation.is_a?(FalseClass) end |
.classify(expectation) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/prism_checker/expectation_classifier.rb', line 17 def self.classify(expectation) EXPECTATIONS_MAP.each do |data| type, probe = data return type if send(probe, expectation) end :other end |
.empty?(expectation) ⇒ Boolean
34 35 36 |
# File 'lib/prism_checker/expectation_classifier.rb', line 34 def self.empty?(expectation) expectation == :empty end |
.hash?(expectation) ⇒ Boolean
50 51 52 |
# File 'lib/prism_checker/expectation_classifier.rb', line 50 def self.hash?(expectation) expectation.is_a?(Hash) end |
.invisible?(expectation) ⇒ Boolean
26 27 28 |
# File 'lib/prism_checker/expectation_classifier.rb', line 26 def self.invisible?(expectation) expectation == :invisible end |
.number?(expectation) ⇒ Boolean
58 59 60 |
# File 'lib/prism_checker/expectation_classifier.rb', line 58 def self.number?(expectation) expectation.is_a?(Integer) end |
.regexp?(expectation) ⇒ Boolean
42 43 44 |
# File 'lib/prism_checker/expectation_classifier.rb', line 42 def self.regexp?(expectation) expectation.is_a?(Regexp) end |
.string?(expectation) ⇒ Boolean
38 39 40 |
# File 'lib/prism_checker/expectation_classifier.rb', line 38 def self.string?(expectation) expectation.is_a?(String) end |
.visible?(expectation) ⇒ Boolean
30 31 32 |
# File 'lib/prism_checker/expectation_classifier.rb', line 30 def self.visible?(expectation) expectation == :visible end |