Skip to content

Commit

Permalink
[ruby/irb] Directly check if the method is available instead of version
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu authored and aycabta committed Aug 18, 2020
1 parent 6aa786b commit 0fcbd07
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/irb/color.rb
Expand Up @@ -146,10 +146,9 @@ def without_circular_ref(obj, seen:, &block)
seen.delete(obj)
end

# Ripper::Lexer::Elem#state is supported on Ruby 2.5+
def supported?
return @supported if defined?(@supported)
@supported = Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.5.0')
@supported = Ripper::Lexer::Elem.method_defined?(:state)
end

def scan(code, allow_last_error:)
Expand Down

0 comments on commit 0fcbd07

Please sign in to comment.