Permalink
Browse files

Calculate parser version number once per class

  • Loading branch information...
presidentbeef committed Nov 7, 2018
1 parent 68800d4 commit 7274aa6df023981fc3c375a9d22bcde781f2cc3f
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/ruby_parser.rb
@@ -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

0 comments on commit 7274aa6

Please sign in to comment.