Skip to content

Commit c6a0abd

Browse files
committed
Use less magical numbers for regular expression flags
1 parent 139362c commit c6a0abd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/yarp.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ class InterpolatedRegularExpressionNode < Node
432432
# Returns a numeric value that represents the flags that were used to create
433433
# the regular expression.
434434
def options
435-
o = flags & 0b111
435+
o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
436436
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
437437
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
438438
o
@@ -450,7 +450,7 @@ class RegularExpressionNode < Node
450450
# Returns a numeric value that represents the flags that were used to create
451451
# the regular expression.
452452
def options
453-
o = flags & 0b111
453+
o = flags & (RegularExpressionFlags::IGNORE_CASE | RegularExpressionFlags::EXTENDED | RegularExpressionFlags::MULTI_LINE)
454454
o |= Regexp::FIXEDENCODING if flags.anybits?(RegularExpressionFlags::EUC_JP | RegularExpressionFlags::WINDOWS_31J | RegularExpressionFlags::UTF_8)
455455
o |= Regexp::NOENCODING if flags.anybits?(RegularExpressionFlags::ASCII_8BIT)
456456
o

0 commit comments

Comments
 (0)