zucker 4 → 5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -1
- data/Rakefile +44 -0
- data/lib/zucker.rb +71 -10
- data/lib/zucker/1/D.rb +2 -0
- data/lib/zucker/1/aliases.rb +2 -0
- data/lib/zucker/1/all.rb +2 -0
- data/lib/zucker/1/array.rb +2 -0
- data/lib/zucker/1/array2proc.rb +2 -0
- data/lib/zucker/1/binding.rb +2 -0
- data/lib/zucker/1/blank.rb +2 -0
- data/lib/zucker/1/class2proc.rb +2 -0
- data/lib/zucker/1/debug.rb +2 -0
- data/lib/zucker/1/default.rb +2 -0
- data/lib/zucker/1/egonil.rb +2 -0
- data/lib/zucker/1/enumerable.rb +2 -0
- data/lib/zucker/1/hash.rb +2 -0
- data/lib/zucker/1/hash2proc.rb +2 -0
- data/lib/zucker/1/iterate.rb +2 -0
- data/lib/zucker/1/ivars.rb +2 -0
- data/lib/zucker/1/kernel.rb +2 -0
- data/lib/zucker/1/mcopy.rb +2 -0
- data/lib/zucker/1/mm.rb +2 -0
- data/lib/zucker/1/regexp2proc.rb +2 -0
- data/lib/zucker/1/sandbox.rb +2 -0
- data/lib/zucker/1/square_brackets_for.rb +2 -0
- data/lib/zucker/1/string.rb +2 -0
- data/lib/zucker/1/unary.rb +2 -0
- data/lib/zucker/1/union.rb +2 -0
- data/lib/zucker/2/D.rb +2 -0
- data/lib/zucker/2/aliases.rb +2 -0
- data/lib/zucker/2/all.rb +2 -0
- data/lib/zucker/2/array.rb +2 -0
- data/lib/zucker/2/array2proc.rb +2 -0
- data/lib/zucker/2/binding.rb +2 -0
- data/lib/zucker/2/blank.rb +2 -0
- data/lib/zucker/2/class2proc.rb +2 -0
- data/lib/zucker/2/debug.rb +2 -0
- data/lib/zucker/2/default.rb +2 -0
- data/lib/zucker/2/egonil.rb +2 -0
- data/lib/zucker/2/enumerable.rb +2 -0
- data/lib/zucker/2/hash.rb +2 -0
- data/lib/zucker/2/hash2proc.rb +2 -0
- data/lib/zucker/2/info.rb +2 -0
- data/lib/zucker/2/iterate.rb +2 -0
- data/lib/zucker/2/ivars.rb +2 -0
- data/lib/zucker/2/kernel.rb +2 -0
- data/lib/zucker/2/mcopy.rb +2 -0
- data/lib/zucker/2/mm.rb +2 -0
- data/lib/zucker/2/regexp2proc.rb +2 -0
- data/lib/zucker/2/sandbox.rb +2 -0
- data/lib/zucker/2/square_brackets_for.rb +2 -0
- data/lib/zucker/2/string.rb +2 -0
- data/lib/zucker/2/unary.rb +2 -0
- data/lib/zucker/2/union.rb +2 -0
- data/lib/zucker/3/D.rb +2 -0
- data/lib/zucker/3/alias_for.rb +2 -0
- data/lib/zucker/3/aliases.rb +2 -0
- data/lib/zucker/3/all.rb +2 -0
- data/lib/zucker/3/array.rb +2 -0
- data/lib/zucker/3/array2proc.rb +2 -0
- data/lib/zucker/3/binding.rb +2 -0
- data/lib/zucker/3/blank.rb +2 -0
- data/lib/zucker/3/class2proc.rb +2 -0
- data/lib/zucker/3/debug.rb +2 -0
- data/lib/zucker/3/default.rb +2 -0
- data/lib/zucker/3/egonil.rb +2 -0
- data/lib/zucker/3/enumerable.rb +2 -0
- data/lib/zucker/3/hash.rb +2 -0
- data/lib/zucker/3/hash2proc.rb +2 -0
- data/lib/zucker/3/info.rb +2 -0
- data/lib/zucker/3/iterate.rb +2 -0
- data/lib/zucker/3/ivars.rb +2 -0
- data/lib/zucker/3/kernel.rb +2 -0
- data/lib/zucker/3/mcopy.rb +2 -0
- data/lib/zucker/3/mm.rb +2 -0
- data/lib/zucker/3/not.rb +2 -0
- data/lib/zucker/3/regexp2proc.rb +2 -0
- data/lib/zucker/3/sandbox.rb +2 -0
- data/lib/zucker/3/square_brackets_for.rb +2 -0
- data/lib/zucker/3/string.rb +2 -0
- data/lib/zucker/3/tap.rb +2 -0
- data/lib/zucker/3/unary.rb +2 -0
- data/lib/zucker/3/union.rb +2 -0
- data/lib/zucker/{D.rb → 4/D.rb} +2 -0
- data/lib/zucker/4/alias_for.rb +21 -0
- data/lib/zucker/4/aliases.rb +35 -0
- data/lib/zucker/4/all.rb +8 -0
- data/lib/zucker/4/array.rb +25 -0
- data/lib/zucker/4/array2proc.rb +18 -0
- data/lib/zucker/4/binding.rb +27 -0
- data/lib/zucker/4/blank.rb +28 -0
- data/lib/zucker/4/class2proc.rb +12 -0
- data/lib/zucker/4/debug.rb +8 -0
- data/lib/zucker/4/default.rb +40 -0
- data/lib/zucker/4/egonil.rb +16 -0
- data/lib/zucker/4/engine.rb +69 -0
- data/lib/zucker/4/enumerable.rb +14 -0
- data/lib/zucker/4/hash.rb +21 -0
- data/lib/zucker/4/hash2proc.rb +16 -0
- data/lib/zucker/4/info.rb +173 -0
- data/lib/zucker/4/iterate.rb +25 -0
- data/lib/zucker/4/ivars.rb +28 -0
- data/lib/zucker/4/kernel.rb +27 -0
- data/lib/zucker/4/mcopy.rb +10 -0
- data/lib/zucker/4/mm.rb +33 -0
- data/lib/zucker/4/not.rb +19 -0
- data/lib/zucker/4/os.rb +50 -0
- data/lib/zucker/{q.rb → 4/q.rb} +2 -0
- data/lib/zucker/4/regexp2proc.rb +12 -0
- data/lib/zucker/4/sandbox.rb +23 -0
- data/lib/zucker/4/square_brackets_for.rb +22 -0
- data/lib/zucker/4/string.rb +54 -0
- data/lib/zucker/4/tap.rb +11 -0
- data/lib/zucker/4/unary.rb +24 -0
- data/lib/zucker/4/union.rb +16 -0
- data/lib/zucker/4/version.rb +115 -0
- data/lib/zucker/5/alias_for.rb +21 -0
- data/lib/zucker/5/aliases.rb +51 -0
- data/lib/zucker/5/all.rb +4 -0
- data/lib/zucker/5/array.rb +25 -0
- data/lib/zucker/5/array2proc.rb +18 -0
- data/lib/zucker/5/binding.rb +34 -0
- data/lib/zucker/5/blank.rb +28 -0
- data/lib/zucker/5/cc.rb +25 -0
- data/lib/zucker/5/class2proc.rb +12 -0
- data/lib/zucker/5/control.rb +4 -0
- data/lib/zucker/5/dd.rb +24 -0
- data/lib/zucker/5/debug.rb +4 -0
- data/lib/zucker/5/default.rb +4 -0
- data/lib/zucker/5/egonil.rb +16 -0
- data/lib/zucker/5/engine.rb +69 -0
- data/lib/zucker/5/enumerable.rb +14 -0
- data/lib/zucker/5/env.rb +4 -0
- data/lib/zucker/5/extensions.rb +4 -0
- data/lib/zucker/5/hash.rb +27 -0
- data/lib/zucker/5/hash2proc.rb +16 -0
- data/lib/zucker/5/info.rb +177 -0
- data/lib/zucker/5/iterate.rb +26 -0
- data/lib/zucker/5/ivars.rb +28 -0
- data/lib/zucker/5/kernel.rb +34 -0
- data/lib/zucker/5/mcopy.rb +10 -0
- data/lib/zucker/5/mm.rb +34 -0
- data/lib/zucker/5/not.rb +19 -0
- data/lib/zucker/5/object.rb +4 -0
- data/lib/zucker/5/oo.rb +17 -0
- data/lib/zucker/5/os.rb +49 -0
- data/lib/zucker/5/qq.rb +12 -0
- data/lib/zucker/5/regexp2proc.rb +12 -0
- data/lib/zucker/5/sandbox.rb +25 -0
- data/lib/zucker/5/shortcuts.rb +4 -0
- data/lib/zucker/5/square_brackets_for.rb +21 -0
- data/lib/zucker/5/string.rb +54 -0
- data/lib/zucker/5/tap.rb +11 -0
- data/lib/zucker/5/to_proc.rb +4 -0
- data/lib/zucker/5/unary.rb +24 -0
- data/lib/zucker/5/union.rb +16 -0
- data/lib/zucker/5/version.rb +118 -0
- data/lib/zucker/alias_for.rb +2 -0
- data/lib/zucker/aliases.rb +19 -1
- data/lib/zucker/all.rb +3 -5
- data/lib/zucker/array.rb +2 -0
- data/lib/zucker/array2proc.rb +2 -0
- data/lib/zucker/binding.rb +5 -0
- data/lib/zucker/blank.rb +2 -0
- data/lib/zucker/cc.rb +25 -0
- data/lib/zucker/class2proc.rb +2 -0
- data/lib/zucker/control.rb +4 -0
- data/lib/zucker/dd.rb +23 -0
- data/lib/zucker/debug.rb +2 -4
- data/lib/zucker/default.rb +2 -36
- data/lib/zucker/egonil.rb +2 -0
- data/lib/zucker/engine.rb +3 -1
- data/lib/zucker/enumerable.rb +2 -0
- data/lib/zucker/env.rb +4 -0
- data/lib/zucker/extensions.rb +4 -0
- data/lib/zucker/hash.rb +8 -0
- data/lib/zucker/hash2proc.rb +2 -0
- data/lib/zucker/info.rb +23 -17
- data/lib/zucker/iterate.rb +3 -0
- data/lib/zucker/ivars.rb +2 -0
- data/lib/zucker/kernel.rb +12 -3
- data/lib/zucker/mcopy.rb +2 -0
- data/lib/zucker/mm.rb +5 -2
- data/lib/zucker/not.rb +2 -0
- data/lib/zucker/object.rb +4 -0
- data/lib/zucker/oo.rb +17 -0
- data/lib/zucker/os.rb +5 -2
- data/lib/zucker/qq.rb +12 -0
- data/lib/zucker/regexp2proc.rb +2 -0
- data/lib/zucker/sandbox.rb +4 -0
- data/lib/zucker/shortcuts.rb +4 -0
- data/lib/zucker/square_brackets_for.rb +13 -12
- data/lib/zucker/string.rb +2 -0
- data/lib/zucker/tap.rb +2 -0
- data/lib/zucker/to_proc.rb +4 -0
- data/lib/zucker/unary.rb +2 -0
- data/lib/zucker/union.rb +2 -0
- data/lib/zucker/version.rb +72 -67
- metadata +87 -5
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
def iterate(*params)
|
4
|
+
# params.shift.zip(*params).each{ |*elements| yield *elements }
|
5
|
+
raise ArgumentError, "wrong number of arguments (0)" if params.empty?
|
6
|
+
|
7
|
+
first = params.shift
|
8
|
+
if params.empty? # single param - like each
|
9
|
+
if block_given?
|
10
|
+
first.map{|e| yield e }
|
11
|
+
else
|
12
|
+
first.map
|
13
|
+
end
|
14
|
+
else
|
15
|
+
padded_first = Array.new( [first, *params].max_by(&:size).size ){|i| first[i] } # append nils
|
16
|
+
obj = padded_first.zip *params
|
17
|
+
if block_given?
|
18
|
+
obj.map{|es| yield *es }
|
19
|
+
else
|
20
|
+
obj.map.to_enum
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# J-_-L
|
26
|
+
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
def instance_variables_from(obj, *only)
|
4
|
+
iter =
|
5
|
+
if obj.is_a? Binding
|
6
|
+
obj.eval('local_variables').map{|e| [obj.eval("#{e}"), e] }
|
7
|
+
elsif obj.is_a? Hash
|
8
|
+
obj.map{|k,v| [v,k] }
|
9
|
+
else
|
10
|
+
# elsif obj.is_a? Enumerable
|
11
|
+
obj.each.with_index
|
12
|
+
end
|
13
|
+
|
14
|
+
ret = []
|
15
|
+
iter.each{ |value, arg|
|
16
|
+
arg = arg.to_s
|
17
|
+
if only.include?(arg) || only.include?(arg.to_sym) || only.empty?
|
18
|
+
arg = '_' + arg if (48..57).member? arg.unpack('C')[0] # 1.8+1.9
|
19
|
+
ret << ivar = :"@#{arg}"
|
20
|
+
self.instance_variable_set ivar, value
|
21
|
+
end
|
22
|
+
}
|
23
|
+
ret
|
24
|
+
end
|
25
|
+
alias ivars instance_variables_from
|
26
|
+
|
27
|
+
# J-_-L
|
28
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
private
|
5
|
+
|
6
|
+
def activate_warnings!
|
7
|
+
$VERBOSE = true
|
8
|
+
end
|
9
|
+
|
10
|
+
def deactivate_warnings!
|
11
|
+
$VERBOSE = false
|
12
|
+
end
|
13
|
+
|
14
|
+
def library?
|
15
|
+
caller[0].rindex(/:\d+(:in `.*')?$/)
|
16
|
+
$PROGRAM_NAME != $` # __FILE__
|
17
|
+
end
|
18
|
+
|
19
|
+
def executed_directly?
|
20
|
+
caller[0].rindex(/:\d+(:in `.*')?$/)
|
21
|
+
$PROGRAM_NAME == $` # __FILE__
|
22
|
+
end
|
23
|
+
alias standalone? executed_directly?
|
24
|
+
|
25
|
+
def irb?
|
26
|
+
!!(( IRB and $0 == 'irb' ) rescue nil)
|
27
|
+
end
|
28
|
+
|
29
|
+
def ignore_sigint! # ctrl+c
|
30
|
+
Signal.trap *%w|SIGINT IGNORE|
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# J-_-L
|
data/lib/zucker/5/mm.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
def m(levels = 1)
|
5
|
+
if self.is_a? Module
|
6
|
+
klass, method_function = self, :public_methods
|
7
|
+
else
|
8
|
+
klass, method_function = self.class, :public_instance_methods
|
9
|
+
|
10
|
+
eigen = self.singleton_methods
|
11
|
+
if !eigen.empty?
|
12
|
+
puts :Eigenclass # sorry for not being up to date, I just love the word
|
13
|
+
p self.singleton_methods
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
levels.times{ |level|
|
18
|
+
if cur = klass.ancestors[level]
|
19
|
+
p cur # put class name
|
20
|
+
p cur.send method_function, false # put methods of the class
|
21
|
+
else
|
22
|
+
break
|
23
|
+
end
|
24
|
+
}
|
25
|
+
|
26
|
+
self # or whatever
|
27
|
+
end
|
28
|
+
|
29
|
+
alias mm m
|
30
|
+
alias method_list m
|
31
|
+
end
|
32
|
+
|
33
|
+
# J-_-L
|
34
|
+
|
data/lib/zucker/5/not.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
class Object
|
4
|
+
def not
|
5
|
+
NotClass.new self
|
6
|
+
end
|
7
|
+
|
8
|
+
class NotClass < BasicObject
|
9
|
+
def initialize(receiver)
|
10
|
+
@receiver = receiver
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_missing(m, *args, &block)
|
14
|
+
not @receiver.public_send( m, *args, &block )
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# J-_-L
|
data/lib/zucker/5/oo.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
private
|
5
|
+
|
6
|
+
def o(desc = nil)
|
7
|
+
caller[0].rindex( /:(\d+)(:in (`.*'))?$/ )
|
8
|
+
m = $3 ? "method #$3, " : ""
|
9
|
+
d = desc ? "#{desc}: r" : 'R'
|
10
|
+
|
11
|
+
puts ret = "#{d}eached #{m}line #$1 of file #$`"
|
12
|
+
# [$`, $1.to_i, $3.to_sym, desc]
|
13
|
+
end
|
14
|
+
alias oo o
|
15
|
+
end
|
16
|
+
|
17
|
+
# J-_-L
|
data/lib/zucker/5/os.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
require 'rbconfig'
|
3
|
+
|
4
|
+
module OS
|
5
|
+
class << self
|
6
|
+
def is?(what)
|
7
|
+
what === RbConfig::CONFIG['host_os']
|
8
|
+
end
|
9
|
+
alias is is?
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
RbConfig::CONFIG['host_os']
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module_function
|
17
|
+
|
18
|
+
def linux?
|
19
|
+
OS.is? /linux|cygwin/
|
20
|
+
end
|
21
|
+
|
22
|
+
def mac?
|
23
|
+
OS.is? /mac|darwin/
|
24
|
+
end
|
25
|
+
|
26
|
+
def bsd?
|
27
|
+
OS.is? /bsd/
|
28
|
+
end
|
29
|
+
|
30
|
+
def windows?
|
31
|
+
OS.is? /mswin|win|mingw/
|
32
|
+
end
|
33
|
+
|
34
|
+
def solaris?
|
35
|
+
OS.is? /solaris|sunos/
|
36
|
+
end
|
37
|
+
|
38
|
+
def posix?
|
39
|
+
linux? or mac? or bsd? or solaris? or Process.respond_to?(:fork)
|
40
|
+
end
|
41
|
+
|
42
|
+
#def symbian?
|
43
|
+
#TODO who knows what symbian returns?
|
44
|
+
#end
|
45
|
+
|
46
|
+
# ...
|
47
|
+
end
|
48
|
+
|
49
|
+
# J-_-L
|
data/lib/zucker/5/qq.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
private
|
5
|
+
|
6
|
+
def sandbox(rescueblock_or_default=nil)
|
7
|
+
Thread.start do
|
8
|
+
$SAFE = 4
|
9
|
+
yield
|
10
|
+
end.value
|
11
|
+
rescue SecurityError => e
|
12
|
+
if !rescueblock_or_default.nil?
|
13
|
+
if rescueblock_or_default.is_a? Proc
|
14
|
+
rescueblock_or_default.call e
|
15
|
+
else
|
16
|
+
rescueblock_or_default
|
17
|
+
end
|
18
|
+
else
|
19
|
+
raise e
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# J-_-L
|
25
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
class Module
|
4
|
+
def square_brackets_for(ivar, assignment = true)
|
5
|
+
# undef [] if respond_to? :[]
|
6
|
+
# undef []= if respond_to? :[]=
|
7
|
+
|
8
|
+
define_method :[] do |key|
|
9
|
+
(instance_variable_get :"@#{ivar}")[key]
|
10
|
+
end
|
11
|
+
|
12
|
+
if assignment
|
13
|
+
define_method :[]= do |key, value|
|
14
|
+
(instance_variable_get :"@#{ivar}")[key] = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# J-_-L
|
21
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
|
3
|
+
class String
|
4
|
+
def -(rem)
|
5
|
+
gsub( Regexp === rem ? rem : rem.to_s, '' )
|
6
|
+
end
|
7
|
+
|
8
|
+
def ^(pos)
|
9
|
+
pos = pos.to_i
|
10
|
+
if pos >= 0
|
11
|
+
self[pos..-1]
|
12
|
+
else
|
13
|
+
self[0...pos]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def lchomp(arg = $/)
|
18
|
+
reverse.chomp(arg).reverse
|
19
|
+
end
|
20
|
+
|
21
|
+
def lchomp!(arg = $/)
|
22
|
+
reverse.chomp!(arg).reverse
|
23
|
+
end
|
24
|
+
|
25
|
+
def ords
|
26
|
+
unpack 'C*'
|
27
|
+
# bytes.to_a
|
28
|
+
end
|
29
|
+
|
30
|
+
def constantize(default_value = nil) # always uses global scope as in AS... is this good?
|
31
|
+
get_constant = lambda{
|
32
|
+
self.split(/::/).inject( Object ){ |base_constant, current_constant|
|
33
|
+
base_constant.const_get current_constant
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
if !default_value && !block_given?
|
38
|
+
get_constant.call
|
39
|
+
else
|
40
|
+
begin
|
41
|
+
get_constant.call
|
42
|
+
rescue NameError
|
43
|
+
if block_given?
|
44
|
+
yield self
|
45
|
+
else
|
46
|
+
default_value
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# J-_-L
|
54
|
+
|
data/lib/zucker/5/tap.rb
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'zucker'
|
2
|
+
require 'date'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module RubyVersion
|
6
|
+
class << self
|
7
|
+
def to_s
|
8
|
+
RUBY_VERSION
|
9
|
+
end
|
10
|
+
|
11
|
+
# comparable
|
12
|
+
def <=>(other)
|
13
|
+
value = case other
|
14
|
+
when Integer
|
15
|
+
RUBY_VERSION.to_i
|
16
|
+
when Float
|
17
|
+
RUBY_VERSION.to_f
|
18
|
+
when String
|
19
|
+
RUBY_VERSION
|
20
|
+
when Date, Time
|
21
|
+
other.class.parse(RUBY_RELEASE_DATE)
|
22
|
+
else
|
23
|
+
other = other.to_s
|
24
|
+
RUBY_VERSION
|
25
|
+
end
|
26
|
+
value <=> other
|
27
|
+
end
|
28
|
+
include Comparable
|
29
|
+
|
30
|
+
# chaining for dsl-like language
|
31
|
+
def is?(other = nil)
|
32
|
+
if other
|
33
|
+
RubyVersion == other
|
34
|
+
else
|
35
|
+
RubyVersion
|
36
|
+
end
|
37
|
+
end
|
38
|
+
alias is is?
|
39
|
+
|
40
|
+
# aliases
|
41
|
+
alias below <
|
42
|
+
alias below? <
|
43
|
+
alias at_most <=
|
44
|
+
alias at_most? <=
|
45
|
+
alias above >
|
46
|
+
alias above? >
|
47
|
+
alias at_least >=
|
48
|
+
alias at_least? >=
|
49
|
+
alias exactly ==
|
50
|
+
alias exactly? ==
|
51
|
+
def not(other)
|
52
|
+
self != other
|
53
|
+
end
|
54
|
+
alias not? not
|
55
|
+
alias between between?
|
56
|
+
|
57
|
+
# compare dates
|
58
|
+
def newer_than(other)
|
59
|
+
if other.is_a? Date or other.is_a? Time
|
60
|
+
RubyVersion > other
|
61
|
+
else
|
62
|
+
RUBY_RELEASE_DATE > other.to_s
|
63
|
+
end
|
64
|
+
end
|
65
|
+
alias newer_than? newer_than
|
66
|
+
|
67
|
+
def older_than(other)
|
68
|
+
if other.is_a? Date or other.is_a? Time
|
69
|
+
RubyVersion < other
|
70
|
+
else
|
71
|
+
RUBY_RELEASE_DATE < other.to_s
|
72
|
+
end
|
73
|
+
end
|
74
|
+
alias older_than? older_than
|
75
|
+
|
76
|
+
def released_today
|
77
|
+
RubyVersion.date == Date.today
|
78
|
+
end
|
79
|
+
alias released_today? released_today
|
80
|
+
|
81
|
+
# accessors
|
82
|
+
|
83
|
+
def major
|
84
|
+
RUBY_VERSION.to_i
|
85
|
+
end
|
86
|
+
alias main major
|
87
|
+
|
88
|
+
def minor
|
89
|
+
RUBY_VERSION.split('.')[1].to_i
|
90
|
+
end
|
91
|
+
alias mini minor
|
92
|
+
|
93
|
+
def tiny
|
94
|
+
RUBY_VERSION.split('.')[2].to_i
|
95
|
+
end
|
96
|
+
|
97
|
+
alias teeny tiny
|
98
|
+
|
99
|
+
def patchlevel
|
100
|
+
RUBY_PATCHLEVEL
|
101
|
+
end
|
102
|
+
|
103
|
+
def platform
|
104
|
+
RUBY_PLATFORM
|
105
|
+
end
|
106
|
+
|
107
|
+
def release_date
|
108
|
+
Date.parse RUBY_RELEASE_DATE
|
109
|
+
end
|
110
|
+
alias date release_date
|
111
|
+
|
112
|
+
def description
|
113
|
+
RUBY_DESCRIPTION
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
# J-_-L
|