Skip to content

Commit

Permalink
Calculate parser version number once per class
Browse files Browse the repository at this point in the history
  • Loading branch information
presidentbeef committed Nov 7, 2018
1 parent 68800d4 commit 7274aa6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/ruby_parser.rb
Expand Up @@ -12,12 +12,19 @@ class RubyParser
class Parser < Racc::Parser
include RubyParserStuff

@version = nil

def self.inherited x
x.version = x.name[/(?:V|Ruby)(\d+)/, 1].to_i
RubyParser::VERSIONS << x
end

def self.version= v
@version = v
end

def self.version
Parser > self and self.name[/(?:V|Ruby)(\d+)/, 1].to_i
@version
end
end

Expand Down

0 comments on commit 7274aa6

Please sign in to comment.