Class: Inspector::Constraint::Violation
- Inherits:
-
Object
- Object
- Inspector::Constraint::Violation
- Defined in:
- lib/inspector/constraint/violation.rb,
lib/inspector/constraint/violation/list.rb
Defined Under Namespace
Classes: List
Instance Attribute Summary collapse
-
#constraint ⇒ Object
readonly
Returns the value of attribute constraint.
Instance Method Summary collapse
-
#initialize(constraint) ⇒ Violation
constructor
A new instance of Violation.
- #inspect ⇒ Object
- #negative? ⇒ Boolean
- #positive? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(constraint) ⇒ Violation
Returns a new instance of Violation.
8 9 10 |
# File 'lib/inspector/constraint/violation.rb', line 8 def initialize(constraint) @constraint = constraint end |
Instance Attribute Details
#constraint ⇒ Object (readonly)
Returns the value of attribute constraint.
6 7 8 |
# File 'lib/inspector/constraint/violation.rb', line 6 def constraint @constraint end |
Instance Method Details
#inspect ⇒ Object
26 27 28 29 30 31 |
# File 'lib/inspector/constraint/violation.rb', line 26 def inspect "#<violated %{type} constraint %{constraint}>" % { :type => @constraint.positive? ? 'positive' : 'negative', :constraint => @constraint.inspect } end |
#negative? ⇒ Boolean
16 17 18 |
# File 'lib/inspector/constraint/violation.rb', line 16 def negative? !@constraint.positive? end |
#positive? ⇒ Boolean
12 13 14 |
# File 'lib/inspector/constraint/violation.rb', line 12 def positive? @constraint.positive? end |
#to_s ⇒ Object
20 21 22 23 24 |
# File 'lib/inspector/constraint/violation.rb', line 20 def to_s expectation = @constraint.positive? ? 'should' : 'should_not' "#{expectation}.#{@constraint}" end |