Class: Pik::VersionParser
Class Method Summary collapse
Instance Method Summary collapse
- #date ⇒ Object
- #full_version ⇒ Object
-
#initialize(version) ⇒ VersionParser
constructor
A new instance of VersionParser.
- #interpreter ⇒ Object
- #match(re) ⇒ Object
- #patchlevel ⇒ Object
- #platform ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(version) ⇒ VersionParser
Returns a new instance of VersionParser.
9 10 11 12 |
# File 'lib/pik/version_parser.rb', line 9 def initialize(version) @version = version @parts = @version.split(/ |\(|\)/).reject{|i| i.empty? } end |
Class Method Details
.parse(version) ⇒ Object
5 6 7 |
# File 'lib/pik/version_parser.rb', line 5 def self.parse(version) new(version) end |
Instance Method Details
#date ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/pik/version_parser.rb', line 23 def date case interpreter when 'IronRuby' nil when 'ruby', 'jruby' md = @version.match(/\d\d\d\d\-\d\d\-\d\d/) md[0] if md end end |
#full_version ⇒ Object
41 42 43 |
# File 'lib/pik/version_parser.rb', line 41 def full_version match(/.+: (.+)/) end |
#interpreter ⇒ Object
14 15 16 |
# File 'lib/pik/version_parser.rb', line 14 def interpreter @interpreter ||= @parts[1] end |
#match(re) ⇒ Object
45 46 47 48 |
# File 'lib/pik/version_parser.rb', line 45 def match(re) md = @version.match(re) md.captures.compact[-1] if md end |
#patchlevel ⇒ Object
37 38 39 |
# File 'lib/pik/version_parser.rb', line 37 def patchlevel match(/patchlevel (\d+)|\dp(\d+)/) end |
#platform ⇒ Object
33 34 35 |
# File 'lib/pik/version_parser.rb', line 33 def platform match(/\[(.+)\]|(\.NET.+)/) end |
#version ⇒ Object
18 19 20 21 |
# File 'lib/pik/version_parser.rb', line 18 def version md = @parts[2].match(/\d\.\d\.\d\.\d|\d\.\d\.\d/) md[0] if md end |