Class: Nitpick::Warnings::UselessBranch
- Inherits:
-
SimpleWarning
- Object
- SimpleWarning
- Nitpick::Warnings::UselessBranch
- Defined in:
- lib/nitpick/warnings/useless_branch.rb
Instance Attribute Summary collapse
-
#no_branch ⇒ Object
readonly
Returns the value of attribute no_branch.
-
#yes_branch ⇒ Object
readonly
Returns the value of attribute yes_branch.
Instance Method Summary collapse
-
#initialize(*args) ⇒ UselessBranch
constructor
A new instance of UselessBranch.
- #matches? ⇒ Boolean
- #message ⇒ Object
Methods inherited from SimpleWarning
Constructor Details
#initialize(*args) ⇒ UselessBranch
Returns a new instance of UselessBranch.
6 7 8 |
# File 'lib/nitpick/warnings/useless_branch.rb', line 6 def initialize(*args) @cond, @yes_branch, @no_branch = args end |
Instance Attribute Details
#no_branch ⇒ Object (readonly)
Returns the value of attribute no_branch.
4 5 6 |
# File 'lib/nitpick/warnings/useless_branch.rb', line 4 def no_branch @no_branch end |
#yes_branch ⇒ Object (readonly)
Returns the value of attribute yes_branch.
4 5 6 |
# File 'lib/nitpick/warnings/useless_branch.rb', line 4 def yes_branch @yes_branch end |
Instance Method Details
#matches? ⇒ Boolean
10 11 12 13 |
# File 'lib/nitpick/warnings/useless_branch.rb', line 10 def matches? (yes_branch == s(:true) and no_branch == s(:false)) or (yes_branch == s(:false) and no_branch == s(:true)) end |
#message ⇒ Object
15 16 17 |
# File 'lib/nitpick/warnings/useless_branch.rb', line 15 def "No need for an if. Just return '#{sexp_to_ruby(@cond)}' as a boolean." end |