Class: Launchy::Detect::RubyEngine
- Inherits:
-
Object
- Object
- Launchy::Detect::RubyEngine
- Extended by:
- Launchy::DescendantTracker
- Defined in:
- lib/launchy/detect/ruby_engine.rb
Defined Under Namespace
Classes: Jruby, MacRuby, Mri, NotFoundError, Rbx
Instance Attribute Summary collapse
-
#ruby_engine ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute ruby_engine.
Class Method Summary collapse
-
.detect(ruby_engine = RubyEngine.new) ⇒ Object
Detect the current ruby engine.
- .is_current_engine?(ruby_engine) ⇒ Boolean
- .jruby? ⇒ Boolean
- .macruby? ⇒ Boolean
- .mri? ⇒ Boolean
- .rbx? ⇒ Boolean
- .ruby_engine_error_message(ruby_engine) ⇒ Object
Instance Method Summary collapse
-
#initialize(ruby_engine = Launchy.ruby_engine) ⇒ RubyEngine
constructor
A new instance of RubyEngine.
Methods included from Launchy::DescendantTracker
children, find_child, inherited
Constructor Details
#initialize(ruby_engine = Launchy.ruby_engine) ⇒ RubyEngine
Returns a new instance of RubyEngine.
40 41 42 43 44 45 46 |
# File 'lib/launchy/detect/ruby_engine.rb', line 40 def initialize( ruby_engine = Launchy.ruby_engine ) if ruby_engine then @ruby_engine = ruby_engine else @ruby_engine = defined?( RUBY_ENGINE ) ? RUBY_ENGINE : "ruby" end end |
Instance Attribute Details
#ruby_engine ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute ruby_engine.
38 39 40 |
# File 'lib/launchy/detect/ruby_engine.rb', line 38 def ruby_engine @ruby_engine end |
Class Method Details
.detect(ruby_engine = RubyEngine.new) ⇒ Object
Detect the current ruby engine.
If the current ruby engine cannot be detected, the return RubyEngine::Unknown
11 12 13 14 15 |
# File 'lib/launchy/detect/ruby_engine.rb', line 11 def self.detect( ruby_engine = RubyEngine.new ) found = find_child( :is_current_engine?, ruby_engine.to_s ) return found if found raise NotFoundError, "#{( ruby_engine )} #{Launchy.}" end |
.is_current_engine?(ruby_engine) ⇒ Boolean
29 30 31 |
# File 'lib/launchy/detect/ruby_engine.rb', line 29 def self.is_current_engine?( ruby_engine ) return ruby_engine == self.engine_name end |
.jruby? ⇒ Boolean
34 |
# File 'lib/launchy/detect/ruby_engine.rb', line 34 def self.jruby?() self == Jruby; end |
.macruby? ⇒ Boolean
36 |
# File 'lib/launchy/detect/ruby_engine.rb', line 36 def self.macruby?() self == MacRuby; end |
.mri? ⇒ Boolean
33 |
# File 'lib/launchy/detect/ruby_engine.rb', line 33 def self.mri?() self == Mri; end |
.rbx? ⇒ Boolean
35 |
# File 'lib/launchy/detect/ruby_engine.rb', line 35 def self.rbx?() self == Rbx; end |
.ruby_engine_error_message(ruby_engine) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/launchy/detect/ruby_engine.rb', line 17 def self.( ruby_engine ) msg = "Unkonwn RUBY_ENGINE " if ruby_engine then msg += " '#{ruby_engine}'." elsif defined?( RUBY_ENGINE ) then msg += " '#{RUBY_ENGINE}'." else msg = "RUBY_ENGINE not defined for #{RUBY_DESCRIPTION}." end return msg end |