Module: System::Ruby
- Defined in:
- lib/system/ruby.rb
Overview
Information about the current Ruby interpreter.
Constant Summary collapse
- C =
The C language.
:c
- CPlusPlus =
The C++ language.
:c_plus_plus
- Java =
The Java language.
:java
- MRI =
The Ruby interpreter: MRI.
:mri
- JRuby =
The Ruby interpreter: JRuby.
:jruby
- Rubinius =
The Ruby interpreter: Rubinius.
:rbx
- MagLev =
The Ruby interpreter: MagLev.
:maglev
Class Method Summary collapse
-
.copyright ⇒ String
Return the current Ruby interpreter’s copyright.
-
.copyright? ⇒ TrueClass, FalseClass
Return if we have information about the copyright.
-
.description ⇒ String
Return the current Ruby interpreter’s description which includes the engine, version, release date, revision, and platform.
-
.description? ⇒ TrueClass, FalseClass
Return if we have information about the description.
-
.engine ⇒ String
Return the current Ruby interpreter’s engine.
-
.engine? ⇒ TrueClass, FalseClass
Return if we have information about the engine.
-
.java? ⇒ TrueClass, FalseClass
Check if Ruby is using Java as it’s base language.
-
.jruby? ⇒ TrueClass, FalseClass
Check if Ruby interpreter is JRuby.
-
.language ⇒ Symbol
Return the current Ruby interpreter’s base language.
-
.name ⇒ Symbol
Return the current Ruby interpreter’s name.
-
.patchlevel ⇒ Integer
Return the current Ruby interpreter’s patch-level.
-
.patchlevel? ⇒ TrueClass, FalseClass
Return if we have information about the patchlevel.
-
.platform ⇒ String
Return the system platform the current Ruby interpreter is running on.
-
.platform? ⇒ TrueClass, FalseClass
Return if we have information about the platform.
-
.release_date ⇒ String
Return the current Ruby interpreter’s release date.
-
.release_date? ⇒ TrueClass, FalseClass
Return if we have information about the release_date.
-
.revision ⇒ Integer
Return the current Ruby interpreter’s revision.
-
.revision? ⇒ TrueClass, FalseClass
Return if we have information about the revision.
-
.ruby? ⇒ TrueClass, FalseClass
Check if Ruby is using C or CPlusPlus as it’s base language.
-
.version ⇒ String
Return the current Ruby interpreter’s version.
-
.version? ⇒ TrueClass, FalseClass
Return if we have information about the version.
Class Method Details
.copyright ⇒ String
Return the current Ruby interpreter’s copyright.
|
# File 'lib/system/ruby.rb', line 41
|
.copyright? ⇒ TrueClass, FalseClass
Return if we have information about the copyright.
|
# File 'lib/system/ruby.rb', line 49
|
.description ⇒ String
Return the current Ruby interpreter’s description which includes the engine, version, release date, revision, and platform.
|
# File 'lib/system/ruby.rb', line 58
|
.description? ⇒ TrueClass, FalseClass
Return if we have information about the description.
|
# File 'lib/system/ruby.rb', line 67
|
.engine ⇒ String
Return the current Ruby interpreter’s engine.
|
# File 'lib/system/ruby.rb', line 76
|
.engine? ⇒ TrueClass, FalseClass
Return if we have information about the engine.
|
# File 'lib/system/ruby.rb', line 84
|
.java? ⇒ TrueClass, FalseClass
Check if Ruby is using Java as it’s base language.
230 231 232 |
# File 'lib/system/ruby.rb', line 230 def java? language == Java end |
.jruby? ⇒ TrueClass, FalseClass
Check if Ruby interpreter is JRuby. Delegates to System::Ruby.jruby? for backwards compatibility.
247 248 249 |
# File 'lib/system/ruby.rb', line 247 def jruby? java? ? engine =~ /jruby/ : false end |
.language ⇒ Symbol
Return the current Ruby interpreter’s base language.
216 217 218 219 220 221 222 223 224 |
# File 'lib/system/ruby.rb', line 216 def language @language ||= if %W[rbx maglev].any? { |name| engine == name } CPlusPlus elsif platform =~ /java/ Java else C end end |
.name ⇒ Symbol
Return the current Ruby interpreter’s name.
196 197 198 199 200 201 202 203 204 205 206 |
# File 'lib/system/ruby.rb', line 196 def name @name ||= if !OS.windows? && ruby? MRI elsif ruby? && engine? && engine == 'rbx' Rubinius elsif ruby? && engine? && engine == 'maglev' MagLev elsif engine? && engine == 'jruby' JRuby end end |
.patchlevel ⇒ Integer
Return the current Ruby interpreter’s patch-level.
|
# File 'lib/system/ruby.rb', line 93
|
.patchlevel? ⇒ TrueClass, FalseClass
Return if we have information about the patchlevel.
|
# File 'lib/system/ruby.rb', line 101
|
.platform ⇒ String
Return the system platform the current Ruby interpreter is running on.
|
# File 'lib/system/ruby.rb', line 110
|
.platform? ⇒ TrueClass, FalseClass
Return if we have information about the platform.
|
# File 'lib/system/ruby.rb', line 118
|
.release_date ⇒ String
Return the current Ruby interpreter’s release date.
|
# File 'lib/system/ruby.rb', line 144
|
.release_date? ⇒ TrueClass, FalseClass
Return if we have information about the release_date.
|
# File 'lib/system/ruby.rb', line 152
|
.revision ⇒ Integer
Return the current Ruby interpreter’s revision.
|
# File 'lib/system/ruby.rb', line 127
|
.revision? ⇒ TrueClass, FalseClass
Return if we have information about the revision.
|
# File 'lib/system/ruby.rb', line 135
|
.ruby? ⇒ TrueClass, FalseClass
Check if Ruby is using C or CPlusPlus as it’s base language.
238 239 240 |
# File 'lib/system/ruby.rb', line 238 def ruby? [C, CPlusPlus].any? { |language| self.language == language } end |
.version ⇒ String
Return the current Ruby interpreter’s version.
|
# File 'lib/system/ruby.rb', line 161
|
.version? ⇒ TrueClass, FalseClass
Return if we have information about the version.
178 179 180 181 182 183 184 185 186 |
# File 'lib/system/ruby.rb', line 178 Object.constants.grep(/^RUBY_/).each do |const_name| method_name = const_name.to_s.gsub(/^RUBY_/, '').downcase.to_sym define_method(method_name) do Object.const_defined?(const_name) ? Object.const_get(const_name) : nil end define_method("#{method_name}?") { !send(method_name).nil? } end |