Module: WhichRuby
- Defined in:
- lib/which_ruby.rb
Constant Summary
collapse
- @@mappings =
{
:rubinius => :rbx,
}
- @@rubies =
[:ruby, :jruby, :rbx]
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
68
69
70
71
72
|
# File 'lib/which_ruby.rb', line 68
def method_missing(sym, *args, &block)
name = strip_sym(sym)
return is_ruby_type?(name) if contains_ruby_type?(name)
super(sym, *args, &block)
end
|
Instance Method Details
#is_ruby_type?(type) ⇒ Boolean
Also known as:
r?
17
18
19
20
|
# File 'lib/which_ruby.rb', line 17
def is_ruby_type?(type)
type = type.to_sym
ruby_type == (@@mappings[type] || type)
end
|
#respond_to?(sym) ⇒ Boolean
64
65
66
|
# File 'lib/which_ruby.rb', line 64
def respond_to?(sym)
contains_ruby_type?(strip_sym(sym)) || super(sym)
end
|
#ruby_copyright ⇒ Object
36
37
38
|
# File 'lib/which_ruby.rb', line 36
def ruby_copyright
RUBY_COPYRIGHT
end
|
#ruby_description ⇒ Object
32
33
34
|
# File 'lib/which_ruby.rb', line 32
def ruby_description
RUBY_DESCRIPTION
end
|
#ruby_engine ⇒ Object
58
59
60
61
62
|
# File 'lib/which_ruby.rb', line 58
def ruby_engine
RUBY_ENGINE
rescue
nil
end
|
#ruby_patchlevel ⇒ Object
40
41
42
|
# File 'lib/which_ruby.rb', line 40
def ruby_patchlevel
RUBY_PATCHLEVEL
end
|
44
45
46
|
# File 'lib/which_ruby.rb', line 44
def ruby_platform
RUBY_PLATFORM
end
|
#ruby_release_date ⇒ Object
48
49
50
|
# File 'lib/which_ruby.rb', line 48
def ruby_release_date
RUBY_RELEASE_DATE
end
|
#ruby_revision ⇒ Object
52
53
54
55
56
|
# File 'lib/which_ruby.rb', line 52
def ruby_revision
RUBY_REVISION
rescue
nil
end
|
#ruby_scope(type) ⇒ Object
24
25
26
|
# File 'lib/which_ruby.rb', line 24
def ruby_scope(type)
yield if is_ruby_type?(type)
end
|
#ruby_type ⇒ Object
Also known as:
rt
9
10
11
12
13
|
# File 'lib/which_ruby.rb', line 9
def ruby_type
return :"#{ruby_engine.downcase}" unless ruby_engine.nil?
ruby_description.match(/\A([^\s]+)/)
:"#{$1.downcase}"
end
|
#ruby_version ⇒ Object
28
29
30
|
# File 'lib/which_ruby.rb', line 28
def ruby_version
RUBY_VERSION
end
|