lib/rubocop/ast/node/if_node.rb in rubocop-ast-0.1.0 vs lib/rubocop/ast/node/if_node.rb in rubocop-ast-0.2.0
- old
+ new
@@ -62,14 +62,13 @@
# for `unless` nodes and vice versa. Returns an empty string for ternary
# operators.
#
# @return [String] the inverse keyword of the `if` statement
def inverse_keyword
- if keyword == 'if'
- 'unless'
- elsif keyword == 'unless'
- 'if'
+ case keyword
+ when 'if' then 'unless'
+ when 'unless' then 'if'
else
''
end
end
@@ -156,14 +155,10 @@
[else_branch]
end
branches.concat(other_branches)
end
- # Calls the given block for each branch node in the conditional statement.
- # If no block is given, an `Enumerator` is returned.
- #
- # @return [self] if a block is given
- # @return [Enumerator] if no block is given
+ # @deprecated Use `branches.each`
def each_branch
return branches.to_enum(__method__) unless block_given?
branches.each do |branch|
yield branch