Class: ActiveStorageValidations::Matchers::RatioValidatorMatcher
- Inherits:
-
Object
- Object
- ActiveStorageValidations::Matchers::RatioValidatorMatcher
- Defined in:
- lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attribute_name) ⇒ RatioValidatorMatcher
constructor
A new instance of RatioValidatorMatcher.
- #is_ratio_in(range_ratio) ⇒ Object
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(attribute_name) ⇒ RatioValidatorMatcher
Returns a new instance of RatioValidatorMatcher.
12 13 14 15 |
# File 'lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb', line 12 def initialize(attribute_name) @attribute_name = attribute_name @ratio_range = nil end |
Instance Method Details
#description ⇒ Object
17 18 19 |
# File 'lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb', line 17 def description "validate image ratio of #{@attribute_name}" end |
#failure_message ⇒ Object
31 32 33 |
# File 'lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb', line 31 def "is expected to validate file size of #{@attribute_name} to be between #{@low} and #{@high} bytes" end |
#failure_message_when_negated ⇒ Object
35 36 37 |
# File 'lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb', line 35 def "is expected to not validate file size of #{@attribute_name} to be between #{@low} and #{@high} bytes" end |
#is_ratio_in(range_ratio) ⇒ Object
21 22 23 24 |
# File 'lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb', line 21 def is_ratio_in range_ratio @range_ratio = range_ratio self end |
#matches?(subject) ⇒ Boolean
26 27 28 29 |
# File 'lib/lupca/carrierwave_image_ratio_validation/matchers/#ratio_validator_matcher.rb', line 26 def matches?(subject) @subject = subject.is_a?(Class) ? subject.new : subject responds_to_methods && valid_ratio? end |