Class: Nitpick::Warnings::UnprotectedBlock
- Inherits:
-
SimpleWarning
- Object
- SimpleWarning
- Nitpick::Warnings::UnprotectedBlock
- Defined in:
- lib/nitpick/warnings/unprotected_block.rb
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
-
#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
- #==(other) ⇒ Object
-
#initialize(*args) ⇒ UnprotectedBlock
constructor
A new instance of UnprotectedBlock.
- #matches? ⇒ Boolean
- #message ⇒ Object
Methods inherited from SimpleWarning
Constructor Details
#initialize(*args) ⇒ UnprotectedBlock
Returns a new instance of UnprotectedBlock.
6 7 8 |
# File 'lib/nitpick/warnings/unprotected_block.rb', line 6 def initialize(*args) @condition, @yes_branch, @no_branch = args end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
4 5 6 |
# File 'lib/nitpick/warnings/unprotected_block.rb', line 4 def condition @condition end |
#no_branch ⇒ Object (readonly)
Returns the value of attribute no_branch.
4 5 6 |
# File 'lib/nitpick/warnings/unprotected_block.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/unprotected_block.rb', line 4 def yes_branch @yes_branch end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 |
# File 'lib/nitpick/warnings/unprotected_block.rb', line 15 def ==(other) yes_branch == other.yes_branch && no_branch == other.no_branch end |
#matches? ⇒ Boolean
10 11 12 13 |
# File 'lib/nitpick/warnings/unprotected_block.rb', line 10 def matches? # raise "YES: #{yes_branch.inspect}" yes_branch =~ s(:yield) && condition !~ s(:fcall, :block_given?) end |
#message ⇒ Object
19 20 21 |
# File 'lib/nitpick/warnings/unprotected_block.rb', line 19 def "A block is being yielded to without a check for block_given?" end |