ampex 0.0.2 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ampex.rb +1 -57
- metadata +8 -18
data/lib/ampex.rb
CHANGED
@@ -24,62 +24,6 @@ class Metavariable < BlankSlate
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
28
|
-
def metavariable_precedence
|
29
|
-
@parent unless @block
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class CallByName < BlankSlate
|
34
|
-
def initialize(obj, parent=nil, name=nil, args=nil, block=nil)
|
35
|
-
@obj = obj
|
36
|
-
@parent = parent
|
37
|
-
@name = name
|
38
|
-
@args = args
|
39
|
-
@block = block
|
40
|
-
end
|
41
|
-
|
42
|
-
def method_missing(name, *args, &block)
|
43
|
-
CallByName.new(nil, self, name, args, block)
|
44
|
-
end
|
45
|
-
|
46
|
-
def unwind_callbyname(*args)
|
47
|
-
provided.map{|x| Metavariable === x ? called[x.metavariable_precedence] : x}
|
48
|
-
if @parent
|
49
|
-
@parent.unwind_callbyname(*args).send(@name, *CallByName.merge_args(@args, args), &@block)
|
50
|
-
else
|
51
|
-
@obj
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def to_proc
|
56
|
-
if @parent
|
57
|
-
lambda { |*args| unwind_callbyname(*args) }
|
58
|
-
else
|
59
|
-
lambda { |*args| @obj }
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def self.merge_args(provided, called)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
class Regexp
|
69
|
-
def [](obj)
|
70
|
-
CallByName.new(obj)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
module Kernel
|
75
|
-
def X
|
76
|
-
Metavariable.new(0)
|
77
|
-
end
|
78
27
|
end
|
79
28
|
|
80
|
-
|
81
|
-
V = Metavariable.new(1)
|
82
|
-
W = Regexp.new""
|
83
|
-
X =
|
84
|
-
Y = Metavariable.new(1)
|
85
|
-
Z = Metavariable.new(2)
|
29
|
+
X = Metavariable.new
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ampex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 9
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
|
9
|
-
version: 0.0.2
|
8
|
+
- 1
|
9
|
+
version: "0.1"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Conrad Irwin
|
@@ -14,22 +14,10 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-11-
|
17
|
+
date: 2010-11-13 00:00:00 +00:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
name: blankslate
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
type: :runtime
|
32
|
-
version_requirements: *id001
|
19
|
+
dependencies: []
|
20
|
+
|
33
21
|
description: Why would you want to write { |x| x['one'] } when you can write &X['one'], why indeed.
|
34
22
|
email: conrad.irwin@gmail.com
|
35
23
|
executables: []
|
@@ -56,6 +44,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
56
44
|
requirements:
|
57
45
|
- - ">="
|
58
46
|
- !ruby/object:Gem::Version
|
47
|
+
hash: 3
|
59
48
|
segments:
|
60
49
|
- 0
|
61
50
|
version: "0"
|
@@ -64,6 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
53
|
requirements:
|
65
54
|
- - ">="
|
66
55
|
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
67
57
|
segments:
|
68
58
|
- 0
|
69
59
|
version: "0"
|