Class: Nitpick::Warnings::AssignmentAsCondition
- Inherits:
-
SimpleWarning
- Object
- SimpleWarning
- Nitpick::Warnings::AssignmentAsCondition
- Defined in:
- lib/nitpick/warnings/assignment_as_condition.rb
Constant Summary collapse
- ASSIGNMENT_NODES =
[:lasgn, :op_asgn_or, :op_asgn_and, :iasgn, :op_asgn1, :gasgn, :dasgn_curr]
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
Instance Method Summary collapse
-
#initialize(*args) ⇒ AssignmentAsCondition
constructor
A new instance of AssignmentAsCondition.
- #matches? ⇒ Boolean
- #message ⇒ Object
Methods inherited from SimpleWarning
Constructor Details
#initialize(*args) ⇒ AssignmentAsCondition
Returns a new instance of AssignmentAsCondition.
9 10 11 |
# File 'lib/nitpick/warnings/assignment_as_condition.rb', line 9 def initialize(*args) @condition = args.shift end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
7 8 9 |
# File 'lib/nitpick/warnings/assignment_as_condition.rb', line 7 def condition @condition end |
Instance Method Details
#matches? ⇒ Boolean
13 14 15 |
# File 'lib/nitpick/warnings/assignment_as_condition.rb', line 13 def matches? ASSIGNMENT_NODES.include? @condition.first end |
#message ⇒ Object
17 18 19 |
# File 'lib/nitpick/warnings/assignment_as_condition.rb', line 17 def "An assigment is being used as a condition: (#{sexp_to_ruby(@condition)})" end |