@@ -1955,11 +1955,12 @@ def format(q)
1955
1955
# If the receiver of this block a Command or CommandCall node, then there
1956
1956
# are no parentheses around the arguments to that command, so we need to
1957
1957
# break the block.
1958
- receiver = q . parent . call
1959
- if receiver . is_a? ( Command ) || receiver . is_a? ( CommandCall )
1958
+ case q . parent
1959
+ in { call : Command | CommandCall }
1960
1960
q . break_parent
1961
1961
format_break ( q , break_opening , break_closing )
1962
1962
return
1963
+ else
1963
1964
end
1964
1965
1965
1966
q . group do
@@ -1978,16 +1979,26 @@ def unchangeable_bounds?(q)
1978
1979
# If we hit a statements, then we're safe to use whatever since we
1979
1980
# know for certain we're going to get split over multiple lines
1980
1981
# anyway.
1981
- break false if parent . is_a? ( Statements ) || parent . is_a? ( ArgParen )
1982
-
1983
- [ Command , CommandCall ] . include? ( parent . class )
1982
+ case parent
1983
+ in Statements | ArgParen
1984
+ break false
1985
+ in Command | CommandCall
1986
+ true
1987
+ else
1988
+ false
1989
+ end
1984
1990
end
1985
1991
end
1986
1992
1987
1993
# If we're a sibling of a control-flow keyword, then we're going to have to
1988
1994
# use the do..end bounds.
1989
1995
def forced_do_end_bounds? ( q )
1990
- [ Break , Next , Return , Super ] . include? ( q . parent . call . class )
1996
+ case q . parent
1997
+ in { call : Break | Next | Return | Super }
1998
+ true
1999
+ else
2000
+ false
2001
+ end
1991
2002
end
1992
2003
1993
2004
# If we're the predicate of a loop or conditional, then we're going to have
@@ -2314,7 +2325,8 @@ def comments
2314
2325
end
2315
2326
2316
2327
def format ( q )
2317
- if operator == :"::" || ( operator . is_a? ( Op ) && operator . value == "::" )
2328
+ case operator
2329
+ in :"::" | Op [ value : "::" ]
2318
2330
q . text ( "." )
2319
2331
else
2320
2332
operator . format ( q )
0 commit comments