Module: Viiite::RubyFacts

Extended by:
RubyFacts
Included in:
Viiite, RubyFacts
Defined in:
lib/viiite/facts/ruby_facts.rb

Instance Method Summary collapse

Instance Method Details

#short_ruby_description(description) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/viiite/facts/ruby_facts.rb', line 12

def short_ruby_description(description)
  case description
  when /Ruby Enterprise Edition (\d{4}\.\d{2})/
    "ree #{$1}"
  when /^(\w+ \d\.\d\.\d) .+ patchlevel (\d+)/
    "#{$1}p#{$2}"
  when /^\w+ \S+/
    $&
  else
    raise "Unknown ruby interpreter: #{description}"
  end
end

#which_rubyObject


4
5
6
7
8
9
10
# File 'lib/viiite/facts/ruby_facts.rb', line 4

def which_ruby
  if Object.const_defined?(:RUBY_DESCRIPTION)
    short_ruby_description(RUBY_DESCRIPTION)
  else
    "ruby #{RUBY_VERSION}"
  end
end