fancy 0.3.3 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +14 -14
- data/Rakefile +16 -4
- data/bin/fancy +3 -0
- data/bin/fspec +20 -0
- data/bin/fyi +27 -11
- data/bin/ifancy +1 -1
- data/boot/fancy_ext.rb +1 -0
- data/boot/fancy_ext/block_env.rb +1 -9
- data/boot/fancy_ext/delegator.rb +64 -0
- data/boot/fancy_ext/object.rb +4 -0
- data/boot/fancy_ext/thread.rb +4 -0
- data/boot/load.rb +5 -1
- data/boot/rbx-compiler/compiler/ast.rb +0 -1
- data/boot/rbx-compiler/compiler/ast/class_def.rb +2 -0
- data/boot/rbx-compiler/compiler/ast/method_def.rb +2 -0
- data/boot/rbx-compiler/compiler/ast/node.rb +10 -0
- data/boot/rbx-compiler/compiler/ast/ruby_args.rb +12 -0
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +2 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/lexer.lex +5 -11
- data/boot/rbx-compiler/parser/parser.rb +16 -5
- data/boot/rbx-compiler/parser/parser.y +39 -24
- data/doc/api/fancy.css +1 -1
- data/doc/api/fancy.jsonp +1 -1
- data/doc/api/fdoc.js +22 -4
- data/doc/api/index.html +5 -6
- data/doc/api/jquery-ui.min.js +401 -0
- data/doc/api/jquery.tools.min.js +192 -0
- data/doc/api/themeswitchertool.js +250 -0
- data/doc/features.md +17 -0
- data/examples/actor_bunnies.fy +32 -0
- data/examples/actors.fy +26 -0
- data/examples/actors_primitive.fy +27 -0
- data/examples/actors_ring.fy +37 -0
- data/examples/armstrong_numbers.fy +1 -1
- data/examples/array.fy +7 -9
- data/examples/async_send.fy +1 -2
- data/examples/blocks.fy +4 -4
- data/examples/call_with_receiver.fy +1 -1
- data/examples/class.fy +1 -1
- data/examples/default_args.fy +4 -1
- data/examples/define_methods.fy +2 -2
- data/examples/echo.fy +1 -1
- data/examples/factorial.fy +1 -1
- data/examples/future_composition.fy +2 -2
- data/examples/futures.fy +0 -5
- data/examples/game_of_life.fy +1 -1
- data/examples/person.fy +1 -1
- data/lib/argv.fy +7 -2
- data/lib/array.fy +109 -42
- data/lib/block.fy +39 -14
- data/lib/boot.fy +2 -0
- data/lib/class.fy +2 -0
- data/lib/compiler/ast.fy +2 -1
- data/lib/compiler/ast/assign.fy +2 -3
- data/lib/compiler/ast/async_send.fy +1 -15
- data/lib/compiler/ast/class_def.fy +2 -1
- data/lib/compiler/ast/expression_list.fy +4 -5
- data/lib/compiler/ast/future_send.fy +1 -10
- data/lib/compiler/ast/goto.fy +46 -0
- data/lib/compiler/ast/identifier.fy +9 -7
- data/lib/compiler/ast/literals.fy +8 -1
- data/lib/compiler/ast/match.fy +14 -4
- data/lib/compiler/ast/message_send.fy +34 -6
- data/lib/compiler/ast/method_def.fy +6 -6
- data/lib/compiler/ast/node.fy +3 -3
- data/lib/compiler/ast/range.fy +1 -0
- data/lib/compiler/ast/script.fy +0 -2
- data/lib/compiler/ast/singleton_method_def.fy +2 -4
- data/lib/compiler/ast/string_interpolation.fy +17 -0
- data/lib/compiler/ast/super.fy +5 -4
- data/lib/compiler/ast/try_catch.fy +8 -6
- data/lib/compiler/ast/tuple_literal.fy +3 -2
- data/lib/compiler/command.fy +0 -1
- data/lib/compiler/compiler.fy +1 -5
- data/lib/compiler/stages.fy +6 -14
- data/lib/documentation.fy +57 -46
- data/lib/enumerable.fy +257 -23
- data/lib/enumerator.fy +122 -15
- data/lib/false_class.fy +10 -1
- data/lib/fancy_spec.fy +263 -61
- data/lib/fdoc.fy +11 -25
- data/lib/fiber.fy +11 -0
- data/lib/file.fy +8 -11
- data/lib/future.fy +84 -5
- data/lib/hash.fy +65 -14
- data/lib/integer.fy +35 -0
- data/lib/iteration.fy +54 -29
- data/lib/message.fy +6 -0
- data/lib/method.fy +0 -16
- data/lib/nil_class.fy +58 -8
- data/lib/number.fy +49 -22
- data/lib/object.fy +371 -65
- data/lib/package.fy +24 -1
- data/lib/package/installer.fy +5 -9
- data/lib/package/specification.fy +2 -2
- data/lib/parser/ext/lexer.lex +15 -11
- data/lib/parser/ext/parser.y +70 -23
- data/lib/parser/methods.fy +33 -14
- data/lib/proxy.fy +33 -3
- data/lib/range.fy +28 -0
- data/lib/rbx.fy +3 -1
- data/lib/rbx/actor.fy +53 -0
- data/lib/rbx/alpha.fy +31 -0
- data/lib/rbx/array.fy +21 -12
- data/lib/rbx/bignum.fy +6 -2
- data/lib/rbx/block.fy +23 -26
- data/lib/rbx/class.fy +54 -2
- data/lib/rbx/code_loader.fy +8 -4
- data/lib/rbx/date.fy +9 -0
- data/lib/rbx/directory.fy +18 -0
- data/lib/rbx/environment_variables.fy +1 -0
- data/lib/rbx/exception.fy +9 -2
- data/lib/rbx/fiber.fy +22 -4
- data/lib/rbx/file.fy +5 -5
- data/lib/rbx/fixnum.fy +5 -0
- data/lib/rbx/float.fy +11 -3
- data/lib/rbx/hash.fy +31 -16
- data/lib/rbx/integer.fy +1 -0
- data/lib/rbx/io.fy +17 -7
- data/lib/rbx/match_data.fy +15 -4
- data/lib/rbx/method.fy +40 -7
- data/lib/rbx/name_error.fy +4 -0
- data/lib/rbx/object.fy +92 -24
- data/lib/rbx/range.fy +20 -6
- data/lib/rbx/regexp.fy +11 -3
- data/lib/rbx/string.fy +51 -1
- data/lib/rbx/stringio.fy +17 -0
- data/lib/rbx/symbol.fy +15 -1
- data/lib/rbx/system.fy +20 -2
- data/lib/rbx/tcp_server.fy +4 -1
- data/lib/rbx/tcp_socket.fy +11 -0
- data/lib/rbx/time.fy +6 -0
- data/lib/rbx/tuple.fy +14 -5
- data/lib/set.fy +144 -29
- data/lib/stack.fy +42 -11
- data/lib/string.fy +118 -8
- data/lib/struct.fy +13 -3
- data/lib/symbol.fy +21 -2
- data/lib/thread_pool.fy +2 -1
- data/lib/true_class.fy +45 -7
- data/lib/tuple.fy +27 -9
- data/lib/version.fy +2 -2
- data/ruby_lib/fancy +43 -0
- data/ruby_lib/fdoc +23 -0
- data/ruby_lib/fspec +3 -0
- data/ruby_lib/fyi +3 -0
- data/ruby_lib/ifancy +3 -0
- data/tests/argv.fy +5 -9
- data/tests/array.fy +323 -196
- data/tests/assignment.fy +29 -29
- data/tests/block.fy +72 -59
- data/tests/class.fy +227 -138
- data/tests/control_flow.fy +83 -51
- data/tests/documentation.fy +8 -8
- data/tests/enumerable.fy +8 -0
- data/tests/enumerator.fy +47 -29
- data/tests/exception.fy +49 -32
- data/tests/file.fy +28 -28
- data/tests/fixnum.fy +170 -0
- data/tests/future.fy +24 -7
- data/tests/hash.fy +55 -38
- data/tests/method.fy +50 -43
- data/tests/nil_class.fy +37 -37
- data/tests/object.fy +152 -70
- data/tests/pattern_matching.fy +67 -31
- data/tests/range.fy +6 -6
- data/tests/set.fy +101 -4
- data/tests/stack.fy +14 -5
- data/tests/string.fy +115 -61
- data/tests/stringio.fy +18 -0
- data/tests/struct.fy +27 -0
- data/tests/symbol.fy +19 -6
- data/tests/true_class.fy +34 -34
- data/tests/tuple.fy +30 -12
- metadata +103 -81
- data/boot/rbx-compiler/compiler/ast/require.rb +0 -20
- data/examples/actor.fy +0 -37
- data/examples/curl_async.fy +0 -37
- data/lib/compiler/ast/require.fy +0 -15
- data/tests/number.fy +0 -135
- data/tests/parsing/sexp.fy +0 -50
data/lib/stack.fy
CHANGED
|
@@ -4,48 +4,79 @@ class Stack {
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
def initialize {
|
|
7
|
+
"""
|
|
8
|
+
Initializes a new Stack.
|
|
9
|
+
"""
|
|
10
|
+
|
|
7
11
|
@arr = []
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
def initialize: size {
|
|
11
|
-
"
|
|
15
|
+
"""
|
|
16
|
+
@size Initial size of the new Stack.
|
|
17
|
+
|
|
18
|
+
Initializes a new Stack with a given size.
|
|
19
|
+
"""
|
|
12
20
|
|
|
13
21
|
@arr = Array new: size
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
def push: obj {
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
@arr << obj
|
|
20
|
-
}
|
|
25
|
+
"""
|
|
26
|
+
@obj Object to be pushed onto @self.
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
"
|
|
28
|
+
Pushes a value onto the Stack.
|
|
29
|
+
"""
|
|
24
30
|
|
|
25
31
|
@arr << obj
|
|
26
32
|
}
|
|
27
33
|
|
|
34
|
+
alias_method: '<< for: 'push:
|
|
35
|
+
|
|
28
36
|
def pop {
|
|
29
|
-
"
|
|
37
|
+
"""
|
|
38
|
+
@return Top-of-stack element.
|
|
39
|
+
|
|
40
|
+
Pops the top-of-stack element from the Stack and returns it.
|
|
41
|
+
"""
|
|
30
42
|
|
|
31
43
|
@arr remove_at: (size - 1)
|
|
32
44
|
}
|
|
33
45
|
|
|
34
46
|
def top {
|
|
35
|
-
"
|
|
47
|
+
"""
|
|
48
|
+
@return The top-of-stack element.
|
|
49
|
+
"""
|
|
36
50
|
|
|
37
51
|
@arr last
|
|
38
52
|
}
|
|
39
53
|
|
|
40
54
|
def size {
|
|
41
|
-
"
|
|
55
|
+
"""
|
|
56
|
+
@return Size of the Stack.
|
|
57
|
+
"""
|
|
42
58
|
|
|
43
59
|
@arr size
|
|
44
60
|
}
|
|
45
61
|
|
|
46
62
|
def empty? {
|
|
47
|
-
"
|
|
63
|
+
"""
|
|
64
|
+
@return @true if empty, otherwise @false.
|
|
65
|
+
|
|
66
|
+
Indicates, if the Stack is empty.
|
|
67
|
+
"""
|
|
48
68
|
|
|
49
69
|
@arr empty?
|
|
50
70
|
}
|
|
71
|
+
|
|
72
|
+
def each: block {
|
|
73
|
+
"""
|
|
74
|
+
@block @Block@ to be called with each element in @self.
|
|
75
|
+
@return @self.
|
|
76
|
+
|
|
77
|
+
Calls a given @Block@ with each element in @self, starting with the top of stack element.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
@arr reverse each: block
|
|
81
|
+
}
|
|
51
82
|
}
|
data/lib/string.fy
CHANGED
|
@@ -11,19 +11,33 @@ class String {
|
|
|
11
11
|
include: FancyEnumerable
|
|
12
12
|
|
|
13
13
|
def ++ other {
|
|
14
|
-
"
|
|
14
|
+
"""
|
|
15
|
+
@other Object to concatenate @self with as a @String@.
|
|
16
|
+
@return Concatenation of @self with @other.
|
|
17
|
+
|
|
18
|
+
Concatenate @self with another Object's @String@ representation.
|
|
19
|
+
\"foo\” ++ 42 # => \”foo42\”
|
|
20
|
+
"""
|
|
15
21
|
|
|
16
22
|
self + (other to_s)
|
|
17
23
|
}
|
|
18
24
|
|
|
19
25
|
def whitespace? {
|
|
20
|
-
"
|
|
26
|
+
"""
|
|
27
|
+
@return @true, if @self consists only of a single whitespace character or is empty, @false otherwise.
|
|
28
|
+
|
|
29
|
+
Indicates, if a @String@ is empty or a single whitespace character.
|
|
30
|
+
"""
|
|
21
31
|
|
|
22
32
|
empty? or: (self == " ")
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
def blank? {
|
|
26
|
-
"
|
|
36
|
+
"""
|
|
37
|
+
@return @true if @self consists only of whitespace, @false otherwise.
|
|
38
|
+
|
|
39
|
+
Indicates, if a @String@ consists only of whitespace.
|
|
40
|
+
"""
|
|
27
41
|
|
|
28
42
|
self =~ /^\s*$/ if_true: {
|
|
29
43
|
true
|
|
@@ -33,26 +47,122 @@ class String {
|
|
|
33
47
|
}
|
|
34
48
|
|
|
35
49
|
def * num {
|
|
36
|
-
"
|
|
50
|
+
"""
|
|
51
|
+
@num Amount of concatenations to do with @self.
|
|
52
|
+
@return @String@ that is the num-fold concatenation of @self.
|
|
53
|
+
|
|
54
|
+
Returns a @String@ that is the num-fold concatenation of itself.
|
|
55
|
+
\"foo\" * 3 # => \”foofoofoo\"
|
|
56
|
+
"""
|
|
37
57
|
|
|
38
58
|
str = ""
|
|
39
59
|
num to_i times: {
|
|
40
|
-
str
|
|
60
|
+
str << self
|
|
41
61
|
}
|
|
42
62
|
str
|
|
43
63
|
}
|
|
44
64
|
|
|
45
65
|
def words {
|
|
66
|
+
"""
|
|
67
|
+
@return @Array@ of all the whitespace seperated words in @self.
|
|
68
|
+
|
|
69
|
+
\"hello world\" words # => [\"hello\", \"world\"]
|
|
70
|
+
"""
|
|
71
|
+
|
|
46
72
|
split
|
|
47
73
|
}
|
|
48
74
|
|
|
49
75
|
def raise! {
|
|
50
|
-
"
|
|
51
|
-
|
|
76
|
+
"""
|
|
77
|
+
Raises a new @StandardError@ with self as the message.
|
|
78
|
+
"""
|
|
79
|
+
|
|
80
|
+
StandardError new: self . raise!
|
|
52
81
|
}
|
|
53
82
|
|
|
54
83
|
def rest {
|
|
55
|
-
"
|
|
84
|
+
"""
|
|
85
|
+
@return @String@ containing all but the first character.
|
|
86
|
+
|
|
87
|
+
Returns a @String@ containing all but the first character.
|
|
88
|
+
\"hello\" rest # => \"ello\"
|
|
89
|
+
"""
|
|
90
|
+
|
|
56
91
|
from: 1 to: -1
|
|
57
92
|
}
|
|
93
|
+
|
|
94
|
+
def lines {
|
|
95
|
+
"""
|
|
96
|
+
@return @Array@ of all the lines in @self.
|
|
97
|
+
|
|
98
|
+
Returns the lines of a @String@ as an @Array@.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
split: "\n"
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
def << object {
|
|
105
|
+
"""
|
|
106
|
+
@object An @Object@ who's @String@ representation will be appended to @self.
|
|
107
|
+
@return @self, but modified.
|
|
108
|
+
|
|
109
|
+
Appends @object's @String@ representation to @self.
|
|
110
|
+
|
|
111
|
+
Example usage:
|
|
112
|
+
str = \"hello\"
|
|
113
|
+
str << \" \"
|
|
114
|
+
str << 42
|
|
115
|
+
str # => \"hello 42\"
|
|
116
|
+
"""
|
|
117
|
+
|
|
118
|
+
append: $ object to_s
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
def skip_leading_indentation {
|
|
122
|
+
"""
|
|
123
|
+
Remove leading white space for multi-line strings.
|
|
124
|
+
This method expects the first character to be an line return.
|
|
125
|
+
"""
|
|
126
|
+
|
|
127
|
+
str = self
|
|
128
|
+
m = /^(\r?\n)*(\s+)/ match(str)
|
|
129
|
+
str = str strip()
|
|
130
|
+
if: m then: {
|
|
131
|
+
pattern = "^ {" ++ (m[2] size()) ++ "}"
|
|
132
|
+
rex = Regexp.new(pattern)
|
|
133
|
+
str = str gsub(rex, "");
|
|
134
|
+
}
|
|
135
|
+
str
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
def characters {
|
|
139
|
+
"""
|
|
140
|
+
@return @Array@ of all characters (as @String@) in @self.
|
|
141
|
+
"""
|
|
142
|
+
|
|
143
|
+
scan: /./
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
def character {
|
|
147
|
+
"""
|
|
148
|
+
@return @Fixnum@ (byte / ASCII) value of first character in @self.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
self bytes each: |c| {
|
|
152
|
+
return c
|
|
153
|
+
}
|
|
154
|
+
return nil
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
def bytes {
|
|
158
|
+
"""
|
|
159
|
+
@return @FancyEnumerator@ of all bytes (@Fixnum@ values) in @self.
|
|
160
|
+
"""
|
|
161
|
+
|
|
162
|
+
enum = bytes()
|
|
163
|
+
def enum each: block {
|
|
164
|
+
each(&block)
|
|
165
|
+
}
|
|
166
|
+
FancyEnumerator new: enum
|
|
167
|
+
}
|
|
58
168
|
}
|
data/lib/struct.fy
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
class Struct {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
"""
|
|
3
|
+
Structs are light-weight classes with predefined read-writable slots.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
def Struct new: slots {
|
|
7
|
+
"""
|
|
8
|
+
@slots @Array@ of slotnames the new Struct should contain.
|
|
9
|
+
|
|
10
|
+
Creates a new Struct class with the given slots.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
struct = new(*slots)
|
|
14
|
+
struct read_write_slots: slots
|
|
5
15
|
|
|
6
16
|
def struct new: values {
|
|
7
17
|
new(*values)
|
data/lib/symbol.fy
CHANGED
|
@@ -14,10 +14,29 @@ class Symbol {
|
|
|
14
14
|
"""
|
|
15
15
|
|
|
16
16
|
if: (arg is_a?: Array) then: {
|
|
17
|
-
arg first
|
|
17
|
+
arg first receive_message: self with_params: $ arg rest
|
|
18
18
|
} else: {
|
|
19
|
-
arg
|
|
19
|
+
arg receive_message: self
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
def call {
|
|
24
|
+
"""
|
|
25
|
+
Sends @self as message to the sender in its context.
|
|
26
|
+
Example:
|
|
27
|
+
'foo call
|
|
28
|
+
# => same as
|
|
29
|
+
self foo
|
|
30
|
+
|
|
31
|
+
if: x then: 'foo else: 'bar
|
|
32
|
+
# same as:
|
|
33
|
+
if: x then: { self foo } else: { self bar }
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
binding = Binding setup(Rubinius VariableScope of_sender(),
|
|
37
|
+
Rubinius CompiledMethod of_sender(),
|
|
38
|
+
Rubinius StaticScope of_sender())
|
|
39
|
+
recv = binding self()
|
|
40
|
+
recv receive_message: self
|
|
41
|
+
}
|
|
23
42
|
}
|
data/lib/thread_pool.fy
CHANGED
data/lib/true_class.fy
CHANGED
|
@@ -1,39 +1,77 @@
|
|
|
1
1
|
class TrueClass {
|
|
2
|
-
"
|
|
2
|
+
"""
|
|
3
|
+
TrueClass. The class of the singleton @true value.
|
|
4
|
+
"""
|
|
3
5
|
|
|
4
6
|
def TrueClass new {
|
|
7
|
+
"""
|
|
8
|
+
@return @true.
|
|
9
|
+
"""
|
|
10
|
+
|
|
5
11
|
# always return true singleton object when trying to create a new
|
|
6
12
|
# TrueClass instance
|
|
7
13
|
true
|
|
8
14
|
}
|
|
9
15
|
|
|
10
16
|
def if_true: block {
|
|
11
|
-
"
|
|
17
|
+
"""
|
|
18
|
+
@block @Block@ to be called with @self.
|
|
19
|
+
@return Value of calling @block with @self.
|
|
20
|
+
|
|
21
|
+
Calls @block with @self.
|
|
22
|
+
"""
|
|
23
|
+
|
|
12
24
|
block call: [self]
|
|
13
25
|
}
|
|
14
26
|
|
|
15
27
|
def if_true: then_block else: else_block {
|
|
16
|
-
"
|
|
28
|
+
"""
|
|
29
|
+
@then_block @Block@ to be called with @self.
|
|
30
|
+
@else_block Gets ignored.
|
|
31
|
+
@return Value of calling @then_block with @self.
|
|
32
|
+
|
|
33
|
+
Calls @then_block with @self.
|
|
34
|
+
"""
|
|
35
|
+
|
|
17
36
|
then_block call: [self]
|
|
18
37
|
}
|
|
19
38
|
|
|
20
39
|
def true? {
|
|
21
|
-
"
|
|
40
|
+
"""
|
|
41
|
+
@return @true.
|
|
42
|
+
"""
|
|
43
|
+
|
|
22
44
|
true
|
|
23
45
|
}
|
|
24
46
|
|
|
25
47
|
def to_s {
|
|
26
|
-
"
|
|
48
|
+
"""
|
|
49
|
+
@return @true as a @String@.
|
|
50
|
+
"""
|
|
51
|
+
|
|
27
52
|
"true"
|
|
28
53
|
}
|
|
29
54
|
|
|
55
|
+
alias_method: 'inspect for: 'to_s
|
|
56
|
+
|
|
30
57
|
def to_a {
|
|
31
|
-
"
|
|
58
|
+
"""
|
|
59
|
+
@return An empty @Array@.
|
|
60
|
+
"""
|
|
61
|
+
|
|
32
62
|
[]
|
|
33
63
|
}
|
|
34
64
|
|
|
35
65
|
def not {
|
|
36
|
-
"
|
|
66
|
+
"""
|
|
67
|
+
@return @false.
|
|
68
|
+
"""
|
|
69
|
+
|
|
37
70
|
false
|
|
38
71
|
}
|
|
39
72
|
}
|
|
73
|
+
|
|
74
|
+
true documentation: """
|
|
75
|
+
@true is the singleton boolean true value (only instance of @TrueClass@).
|
|
76
|
+
TrueClass##new yields @true.
|
|
77
|
+
"""
|
data/lib/tuple.fy
CHANGED
|
@@ -6,7 +6,7 @@ class Tuple {
|
|
|
6
6
|
|
|
7
7
|
include: FancyEnumerable
|
|
8
8
|
|
|
9
|
-
def []
|
|
9
|
+
def [idx] {
|
|
10
10
|
"""
|
|
11
11
|
Forwards to @Tuple@#at:.
|
|
12
12
|
"""
|
|
@@ -15,22 +15,34 @@ class Tuple {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
def first {
|
|
18
|
-
"
|
|
18
|
+
"""
|
|
19
|
+
@return The first element in @self.
|
|
20
|
+
"""
|
|
21
|
+
|
|
19
22
|
at: 0
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
def second {
|
|
23
|
-
"
|
|
26
|
+
"""
|
|
27
|
+
@return The second element in @self.
|
|
28
|
+
"""
|
|
29
|
+
|
|
24
30
|
at: 1
|
|
25
31
|
}
|
|
26
32
|
|
|
27
33
|
def third {
|
|
28
|
-
"
|
|
34
|
+
"""
|
|
35
|
+
@return The third element in @self.
|
|
36
|
+
"""
|
|
37
|
+
|
|
29
38
|
at: 2
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
def fourth {
|
|
33
|
-
"
|
|
42
|
+
"""
|
|
43
|
+
@return The fourth element in @self.
|
|
44
|
+
"""
|
|
45
|
+
|
|
34
46
|
at: 3
|
|
35
47
|
}
|
|
36
48
|
|
|
@@ -71,15 +83,17 @@ class Tuple {
|
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
def inspect {
|
|
74
|
-
"
|
|
86
|
+
"""
|
|
87
|
+
@return A @String@ representation of @self.
|
|
88
|
+
"""
|
|
75
89
|
|
|
76
90
|
str = "("
|
|
77
91
|
each: |v| {
|
|
78
|
-
str
|
|
92
|
+
str << (v inspect)
|
|
79
93
|
} in_between: {
|
|
80
|
-
str
|
|
94
|
+
str << ", "
|
|
81
95
|
}
|
|
82
|
-
str
|
|
96
|
+
str << ")"
|
|
83
97
|
str
|
|
84
98
|
}
|
|
85
99
|
|
|
@@ -96,4 +110,8 @@ class Tuple {
|
|
|
96
110
|
[obj] + (obj map: 'identity)
|
|
97
111
|
}
|
|
98
112
|
}
|
|
113
|
+
|
|
114
|
+
def Tuple name {
|
|
115
|
+
"Tuple"
|
|
116
|
+
}
|
|
99
117
|
}
|