fancy 0.3.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/AUTHORS +7 -0
- data/LICENSE +19 -0
- data/README +173 -0
- data/Rakefile +255 -0
- data/bin/fancy +40 -0
- data/bin/fdoc +23 -0
- data/bin/fyi +22 -0
- data/bin/ifancy +46 -0
- data/boot/README +12 -0
- data/boot/code_loader.rb +165 -0
- data/boot/compile.fy +3 -0
- data/boot/fancy_ext.rb +13 -0
- data/boot/fancy_ext/block_env.rb +29 -0
- data/boot/fancy_ext/class.rb +26 -0
- data/boot/fancy_ext/kernel.rb +12 -0
- data/boot/fancy_ext/module.rb +89 -0
- data/boot/fancy_ext/object.rb +34 -0
- data/boot/fancy_ext/string_helper.rb +10 -0
- data/boot/load.rb +72 -0
- data/boot/rbx-compiler/README +12 -0
- data/boot/rbx-compiler/compiler.rb +24 -0
- data/boot/rbx-compiler/compiler/ast.rb +23 -0
- data/boot/rbx-compiler/compiler/ast/README +11 -0
- data/boot/rbx-compiler/compiler/ast/array_literal.rb +13 -0
- data/boot/rbx-compiler/compiler/ast/assign.rb +57 -0
- data/boot/rbx-compiler/compiler/ast/block.rb +70 -0
- data/boot/rbx-compiler/compiler/ast/class_def.rb +35 -0
- data/boot/rbx-compiler/compiler/ast/expression_list.rb +57 -0
- data/boot/rbx-compiler/compiler/ast/hash_literal.rb +11 -0
- data/boot/rbx-compiler/compiler/ast/identifier.rb +120 -0
- data/boot/rbx-compiler/compiler/ast/match.rb +81 -0
- data/boot/rbx-compiler/compiler/ast/message_send.rb +71 -0
- data/boot/rbx-compiler/compiler/ast/method_def.rb +116 -0
- data/boot/rbx-compiler/compiler/ast/node.rb +6 -0
- data/boot/rbx-compiler/compiler/ast/range_literal.rb +22 -0
- data/boot/rbx-compiler/compiler/ast/require.rb +20 -0
- data/boot/rbx-compiler/compiler/ast/return.rb +29 -0
- data/boot/rbx-compiler/compiler/ast/ruby_args.rb +35 -0
- data/boot/rbx-compiler/compiler/ast/script.rb +56 -0
- data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +39 -0
- data/boot/rbx-compiler/compiler/ast/string_literal.rb +14 -0
- data/boot/rbx-compiler/compiler/ast/super.rb +25 -0
- data/boot/rbx-compiler/compiler/ast/try_catch_block.rb +220 -0
- data/boot/rbx-compiler/compiler/ast/tuple_literal.rb +33 -0
- data/boot/rbx-compiler/compiler/command.rb +39 -0
- data/boot/rbx-compiler/compiler/compiler.rb +83 -0
- data/boot/rbx-compiler/compiler/stages.rb +99 -0
- data/boot/rbx-compiler/parser.rb +2 -0
- data/boot/rbx-compiler/parser/README +15 -0
- data/boot/rbx-compiler/parser/Rakefile +54 -0
- data/boot/rbx-compiler/parser/extconf.rb +3 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/fancy_parser.c +46 -0
- data/boot/rbx-compiler/parser/fancy_parser.h +8 -0
- data/boot/rbx-compiler/parser/lexer.lex +180 -0
- data/boot/rbx-compiler/parser/parser.rb +356 -0
- data/boot/rbx-compiler/parser/parser.y +711 -0
- data/boot/rsexp_pretty_printer.rb +76 -0
- data/doc/api/fancy.css +93 -0
- data/doc/api/fancy.jsonp +1 -0
- data/doc/api/fdoc.js +187 -0
- data/doc/api/index.html +57 -0
- data/doc/api/underscore-min.js +18 -0
- data/doc/features.md +228 -0
- data/examples/argv.fy +8 -0
- data/examples/arithmetic.fy +7 -0
- data/examples/armstrong_numbers.fy +33 -0
- data/examples/array.fy +52 -0
- data/examples/blocks.fy +15 -0
- data/examples/boolean.fy +24 -0
- data/examples/call_with_receiver.fy +9 -0
- data/examples/class.fy +68 -0
- data/examples/closures.fy +24 -0
- data/examples/constant_access.fy +15 -0
- data/examples/default_args.fy +17 -0
- data/examples/define_methods.fy +15 -0
- data/examples/documentation.fy +57 -0
- data/examples/documentation_formatters.fy +25 -0
- data/examples/echo.fy +16 -0
- data/examples/empty_catch.fy +4 -0
- data/examples/exception.fy +9 -0
- data/examples/factorial.fy +12 -0
- data/examples/fibonacci.fy +16 -0
- data/examples/files.fy +23 -0
- data/examples/finally.fy +5 -0
- data/examples/game_of_life.fy +148 -0
- data/examples/hashes.fy +7 -0
- data/examples/hello_world.fy +6 -0
- data/examples/html_generator.fy +54 -0
- data/examples/implicit_return.fy +3 -0
- data/examples/matchers.fy +6 -0
- data/examples/methods.fy +29 -0
- data/examples/nested_classes.fy +27 -0
- data/examples/nested_try.fy +9 -0
- data/examples/numbers.fy +12 -0
- data/examples/pattern_matching.fy +40 -0
- data/examples/person.fy +65 -0
- data/examples/project-euler/01.fy +8 -0
- data/examples/project-euler/02.fy +21 -0
- data/examples/project-euler/28.fy +33 -0
- data/examples/rbx/and_or.fy +7 -0
- data/examples/rbx/blocks.fy +22 -0
- data/examples/rbx/classes.fy +32 -0
- data/examples/rbx/hello.fy +8 -0
- data/examples/rbx/include.fy +12 -0
- data/examples/rbx/inherit.fy +11 -0
- data/examples/rbx/methods.fy +15 -0
- data/examples/rbx/nested_classes.fy +9 -0
- data/examples/rbx/require.fy +3 -0
- data/examples/rbx/strings.fy +5 -0
- data/examples/regex.fy +7 -0
- data/examples/require.fy +7 -0
- data/examples/retry.fy +12 -0
- data/examples/return.fy +13 -0
- data/examples/ruby_require.fy +7 -0
- data/examples/ruby_send.fy +3 -0
- data/examples/singleton_methods.fy +21 -0
- data/examples/stupid_quicksort.fy +12 -0
- data/examples/threads.fy +18 -0
- data/examples/tuple.fy +8 -0
- data/examples/webserver/webserver.fy +18 -0
- data/lib/argv.fy +36 -0
- data/lib/array.fy +207 -0
- data/lib/block.fy +88 -0
- data/lib/boot.fy +41 -0
- data/lib/class.fy +106 -0
- data/lib/compiler.fy +14 -0
- data/lib/compiler/ast.fy +40 -0
- data/lib/compiler/ast/assign.fy +96 -0
- data/lib/compiler/ast/block.fy +84 -0
- data/lib/compiler/ast/class_def.fy +33 -0
- data/lib/compiler/ast/expression_list.fy +47 -0
- data/lib/compiler/ast/identifier.fy +113 -0
- data/lib/compiler/ast/literals.fy +122 -0
- data/lib/compiler/ast/match.fy +88 -0
- data/lib/compiler/ast/message_send.fy +110 -0
- data/lib/compiler/ast/method_def.fy +90 -0
- data/lib/compiler/ast/node.fy +7 -0
- data/lib/compiler/ast/range.fy +16 -0
- data/lib/compiler/ast/require.fy +15 -0
- data/lib/compiler/ast/return.fy +23 -0
- data/lib/compiler/ast/script.fy +52 -0
- data/lib/compiler/ast/singleton_method_def.fy +35 -0
- data/lib/compiler/ast/super.fy +17 -0
- data/lib/compiler/ast/try_catch.fy +176 -0
- data/lib/compiler/ast/tuple_literal.fy +34 -0
- data/lib/compiler/command.fy +51 -0
- data/lib/compiler/compiler.fy +73 -0
- data/lib/compiler/stages.fy +81 -0
- data/lib/directory.fy +17 -0
- data/lib/documentation.fy +115 -0
- data/lib/enumerable.fy +269 -0
- data/lib/eval.fy +31 -0
- data/lib/fancy_spec.fy +202 -0
- data/lib/fdoc.fy +359 -0
- data/lib/fdoc_hook.fy +10 -0
- data/lib/file.fy +54 -0
- data/lib/hash.fy +56 -0
- data/lib/main.fy +80 -0
- data/lib/method.fy +22 -0
- data/lib/nil_class.fy +56 -0
- data/lib/number.fy +87 -0
- data/lib/object.fy +170 -0
- data/lib/package.fy +61 -0
- data/lib/package/dependency.fy +24 -0
- data/lib/package/installer.fy +180 -0
- data/lib/package/specification.fy +55 -0
- data/lib/package/uninstaller.fy +15 -0
- data/lib/parser.fy +4 -0
- data/lib/parser/ext/README +15 -0
- data/lib/parser/ext/ext.c +42 -0
- data/lib/parser/ext/ext.h +8 -0
- data/lib/parser/ext/extconf.rb +3 -0
- data/lib/parser/ext/lexer.lex +187 -0
- data/lib/parser/ext/parser.y +744 -0
- data/lib/parser/methods.fy +297 -0
- data/lib/rbx.fy +37 -0
- data/lib/rbx/array.fy +237 -0
- data/lib/rbx/bignum.fy +23 -0
- data/lib/rbx/block.fy +9 -0
- data/lib/rbx/class.fy +129 -0
- data/lib/rbx/code_loader.fy +192 -0
- data/lib/rbx/console.fy +63 -0
- data/lib/rbx/directory.fy +46 -0
- data/lib/rbx/documentation.fy +64 -0
- data/lib/rbx/environment_variables.fy +3 -0
- data/lib/rbx/exception.fy +30 -0
- data/lib/rbx/false_class.fy +58 -0
- data/lib/rbx/fiber.fy +25 -0
- data/lib/rbx/file.fy +191 -0
- data/lib/rbx/fixnum.fy +25 -0
- data/lib/rbx/float.fy +14 -0
- data/lib/rbx/hash.fy +38 -0
- data/lib/rbx/integer.fy +15 -0
- data/lib/rbx/io.fy +30 -0
- data/lib/rbx/match_data.fy +9 -0
- data/lib/rbx/method.fy +22 -0
- data/lib/rbx/name_error.fy +3 -0
- data/lib/rbx/no_method_error.fy +15 -0
- data/lib/rbx/object.fy +117 -0
- data/lib/rbx/range.fy +15 -0
- data/lib/rbx/regexp.fy +9 -0
- data/lib/rbx/string.fy +63 -0
- data/lib/rbx/symbol.fy +12 -0
- data/lib/rbx/system.fy +37 -0
- data/lib/rbx/tcp_server.fy +6 -0
- data/lib/rbx/tcp_socket.fy +7 -0
- data/lib/rbx/thread.fy +75 -0
- data/lib/rbx/tuple.fy +37 -0
- data/lib/set.fy +61 -0
- data/lib/stack.fy +51 -0
- data/lib/string.fy +58 -0
- data/lib/struct.fy +13 -0
- data/lib/symbol.fy +23 -0
- data/lib/true_class.fy +43 -0
- data/lib/tuple.fy +68 -0
- data/lib/version.fy +6 -0
- data/tests/argv.fy +13 -0
- data/tests/array.fy +343 -0
- data/tests/assignment.fy +53 -0
- data/tests/block.fy +103 -0
- data/tests/class.fy +409 -0
- data/tests/control_flow.fy +79 -0
- data/tests/documentation.fy +24 -0
- data/tests/exception.fy +115 -0
- data/tests/file.fy +86 -0
- data/tests/hash.fy +101 -0
- data/tests/method.fy +131 -0
- data/tests/nil_class.fy +55 -0
- data/tests/number.fy +128 -0
- data/tests/object.fy +125 -0
- data/tests/parsing/sexp.fy +50 -0
- data/tests/pattern_matching.fy +82 -0
- data/tests/range.fy +11 -0
- data/tests/set.fy +10 -0
- data/tests/stack.fy +22 -0
- data/tests/string.fy +102 -0
- data/tests/symbol.fy +17 -0
- data/tests/true_class.fy +63 -0
- data/tests/tuple.fy +21 -0
- data/tools/fancy-mode.el +63 -0
- metadata +321 -0
@@ -0,0 +1,64 @@
|
|
1
|
+
# create the fancy namespace
|
2
|
+
class Fancy {}
|
3
|
+
|
4
|
+
class Fancy Documentation {
|
5
|
+
|
6
|
+
def initialize: docstring {
|
7
|
+
@docs = [docstring]
|
8
|
+
}
|
9
|
+
|
10
|
+
def meta: @meta { }
|
11
|
+
def meta { @meta }
|
12
|
+
|
13
|
+
# A list of handlers that would like to get adviced when
|
14
|
+
# an object has been set documentation.
|
15
|
+
@on_documentation_set = []
|
16
|
+
|
17
|
+
def self on_documentation_set: block {
|
18
|
+
@on_documentation_set unshift(block)
|
19
|
+
}
|
20
|
+
|
21
|
+
def self documentation_for: obj set_to: doc {
|
22
|
+
@on_documentation_set each() |block| { block call: [obj, doc] }
|
23
|
+
}
|
24
|
+
|
25
|
+
def self for: obj is: docstring {
|
26
|
+
"""
|
27
|
+
Create a Fancy::Documentation instance.
|
28
|
+
|
29
|
+
Note: As we're bootstrapping, we cannot set documentation here as
|
30
|
+
an string literal.
|
31
|
+
|
32
|
+
We are the very first thing to load, so just create a new
|
33
|
+
Fancy::Documentation object without using new:, and set it as
|
34
|
+
fancy docs.
|
35
|
+
"""
|
36
|
+
|
37
|
+
doc = self allocate()
|
38
|
+
doc send('initialize:, docstring to_s)
|
39
|
+
obj instance_variable_set('@_fancy_documentation, doc)
|
40
|
+
|
41
|
+
self documentation_for: obj set_to: doc
|
42
|
+
doc
|
43
|
+
}
|
44
|
+
|
45
|
+
self for: (instance_method('initialize:)) is: "Create a new documentation object."
|
46
|
+
self for: (method('for:is:)) is: "Sets the documentation for obj."
|
47
|
+
|
48
|
+
def self for: obj {
|
49
|
+
"Obtains the Fancy Documentation for obj."
|
50
|
+
doc = obj instance_variable_get('@_fancy_documentation)
|
51
|
+
}
|
52
|
+
|
53
|
+
def self remove: obj {
|
54
|
+
"Removes the documentation for obj."
|
55
|
+
obj remove_instance_variable('@_fancy_documentation)
|
56
|
+
}
|
57
|
+
|
58
|
+
def self for: obj append: docstring {
|
59
|
+
"Append docstring to docs."
|
60
|
+
self for: obj is: docstring
|
61
|
+
}
|
62
|
+
|
63
|
+
}
|
64
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class StandardError {
|
2
|
+
ruby_alias: 'message
|
3
|
+
|
4
|
+
def initialize {
|
5
|
+
"Creates a new Exception with an empty message."
|
6
|
+
|
7
|
+
initialize()
|
8
|
+
}
|
9
|
+
|
10
|
+
def initialize: msg {
|
11
|
+
"""
|
12
|
+
@msg Message (@String@) for the Exception.
|
13
|
+
|
14
|
+
Creates a new Exception with a given message.
|
15
|
+
"""
|
16
|
+
|
17
|
+
self initialize(msg)
|
18
|
+
}
|
19
|
+
|
20
|
+
def raise! {
|
21
|
+
"""
|
22
|
+
Raises (throws) an Exception to be caught somewhere up the
|
23
|
+
callstack.
|
24
|
+
"""
|
25
|
+
|
26
|
+
raise(self)
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
StdError = StandardError
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class FalseClass {
|
2
|
+
"""
|
3
|
+
FalseClass extensions for Fancy on rbx.
|
4
|
+
"""
|
5
|
+
|
6
|
+
def if_true: then_block else: else_block {
|
7
|
+
"Calls else_block."
|
8
|
+
else_block call
|
9
|
+
}
|
10
|
+
|
11
|
+
def if_true: block {
|
12
|
+
"Returns nil."
|
13
|
+
nil
|
14
|
+
}
|
15
|
+
|
16
|
+
def if_false: block {
|
17
|
+
"Calls the block."
|
18
|
+
block call
|
19
|
+
}
|
20
|
+
|
21
|
+
def if_nil: block {
|
22
|
+
"Calls the block."
|
23
|
+
nil
|
24
|
+
}
|
25
|
+
|
26
|
+
def nil? {
|
27
|
+
"Returns true."
|
28
|
+
false
|
29
|
+
}
|
30
|
+
|
31
|
+
def false? {
|
32
|
+
"Returns true."
|
33
|
+
true
|
34
|
+
}
|
35
|
+
|
36
|
+
def true? {
|
37
|
+
"Returns nil."
|
38
|
+
false
|
39
|
+
}
|
40
|
+
|
41
|
+
def to_s {
|
42
|
+
"false"
|
43
|
+
}
|
44
|
+
|
45
|
+
def to_a {
|
46
|
+
[]
|
47
|
+
}
|
48
|
+
|
49
|
+
def not {
|
50
|
+
"""
|
51
|
+
@return @true
|
52
|
+
|
53
|
+
Boolean negation of @false => @true.
|
54
|
+
"""
|
55
|
+
|
56
|
+
true
|
57
|
+
}
|
58
|
+
}
|
data/lib/rbx/fiber.fy
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require("fiber")
|
2
|
+
|
3
|
+
Fiber = Rubinius Fiber
|
4
|
+
|
5
|
+
class Fiber {
|
6
|
+
def self new: block {
|
7
|
+
new(&block)
|
8
|
+
}
|
9
|
+
|
10
|
+
def Fiber yield {
|
11
|
+
yield()
|
12
|
+
}
|
13
|
+
|
14
|
+
def Fiber yield: vals {
|
15
|
+
yield(*vals)
|
16
|
+
}
|
17
|
+
|
18
|
+
def resume {
|
19
|
+
resume()
|
20
|
+
}
|
21
|
+
|
22
|
+
def resume: vals {
|
23
|
+
resume(*vals)
|
24
|
+
}
|
25
|
+
}
|
data/lib/rbx/file.fy
ADDED
@@ -0,0 +1,191 @@
|
|
1
|
+
class File {
|
2
|
+
@@open_mode_conversions =
|
3
|
+
<['read => "r",
|
4
|
+
'write => "w",
|
5
|
+
'append => "+",
|
6
|
+
'at_end => "a",
|
7
|
+
'binary => "b",
|
8
|
+
'truncate => "w+"]>
|
9
|
+
|
10
|
+
ruby_alias: 'eof?
|
11
|
+
#ruby_alias: 'close
|
12
|
+
ruby_alias: 'closed?
|
13
|
+
|
14
|
+
def File open: filename modes: modes_arr with: block {
|
15
|
+
"""
|
16
|
+
@filename Filename to open/create.
|
17
|
+
@modes_arr Array of symbols that describe the desired operations to perform.
|
18
|
+
@block @Block@ that gets called with the @File@ object that has been opened.
|
19
|
+
|
20
|
+
Opens a File with a given @filename, a @modes_arr (@Array@) and a @block.
|
21
|
+
|
22
|
+
E.g. to open a File with read access and read all lines and print them to STDOUT:
|
23
|
+
|
24
|
+
File open: \"foo.txt\" modes: [:read] with: |f| {
|
25
|
+
{ f eof? } while_false: {
|
26
|
+
f readln println
|
27
|
+
}
|
28
|
+
}
|
29
|
+
"""
|
30
|
+
|
31
|
+
modes_str = modes_str: modes_arr
|
32
|
+
|
33
|
+
try {
|
34
|
+
open(filename, modes_str, &block)
|
35
|
+
} catch Errno::ENOENT => e {
|
36
|
+
IOError new: (e message) . raise!
|
37
|
+
}
|
38
|
+
}
|
39
|
+
|
40
|
+
def File exists?: filename {
|
41
|
+
"""
|
42
|
+
@filename Path to file to check for existance.
|
43
|
+
@return @true if @File@ exists, @false otherwise.
|
44
|
+
|
45
|
+
Indicates if the @File@ with the given @filename exists.
|
46
|
+
"""
|
47
|
+
|
48
|
+
File exists?(filename)
|
49
|
+
}
|
50
|
+
|
51
|
+
def close {
|
52
|
+
"""
|
53
|
+
Closes an opened @File@.
|
54
|
+
"""
|
55
|
+
|
56
|
+
try {
|
57
|
+
close()
|
58
|
+
} catch Errno::ENOENT => e {
|
59
|
+
IOError new: (e message) . raise!
|
60
|
+
}
|
61
|
+
}
|
62
|
+
|
63
|
+
def File open: filename modes: modes_arr {
|
64
|
+
"""
|
65
|
+
@filename Filename to open/create.
|
66
|
+
@modes_arr Array of symbols that describe the desired operations to perform.
|
67
|
+
@return A @File@ instance that represents the opened @File@.
|
68
|
+
|
69
|
+
Similar to open:modes:with: but takes no @Block@ argument to be
|
70
|
+
called with the @File@ instance.
|
71
|
+
Returns the opened @File@ instead and expects the caller to @close it manually.
|
72
|
+
"""
|
73
|
+
|
74
|
+
modes_str = modes_str: modes_arr
|
75
|
+
f = nil
|
76
|
+
try {
|
77
|
+
f = open(filename, modes_str)
|
78
|
+
f modes: modes_arr
|
79
|
+
} catch Errno::ENOENT => e {
|
80
|
+
IOError new: (e message) . raise!
|
81
|
+
}
|
82
|
+
f
|
83
|
+
}
|
84
|
+
|
85
|
+
def File modes_str: modes_arr {
|
86
|
+
"""
|
87
|
+
@modes_arr Array of symbols that describe the desired operations to perform.
|
88
|
+
@return @String@ that represents the @File@ access modifiers, as used by Ruby.
|
89
|
+
|
90
|
+
Returns the appropriate @String@ representation of the @modes_arr.
|
91
|
+
"""
|
92
|
+
|
93
|
+
str = ""
|
94
|
+
modes_arr each: |m| {
|
95
|
+
str = str ++ (@@open_mode_conversions[m])
|
96
|
+
}
|
97
|
+
str uniq join: ""
|
98
|
+
}
|
99
|
+
|
100
|
+
def File delete: filename {
|
101
|
+
"""
|
102
|
+
@filename Path to @File@ to be deleted.
|
103
|
+
|
104
|
+
Deletes a @File@ with a given @filename.
|
105
|
+
"""
|
106
|
+
|
107
|
+
try {
|
108
|
+
delete(filename)
|
109
|
+
} catch Errno::ENOENT => e {
|
110
|
+
IOError new: (e message) . raise!
|
111
|
+
}
|
112
|
+
}
|
113
|
+
|
114
|
+
def File directory?: path {
|
115
|
+
"""
|
116
|
+
@path Path to check if it's a @Directory@.
|
117
|
+
@return @true, if the @path refers to a @Directory@, @false otherwise.
|
118
|
+
|
119
|
+
Indicates, if a given @path refers to a @Directory@.
|
120
|
+
"""
|
121
|
+
|
122
|
+
directory?(path)
|
123
|
+
}
|
124
|
+
|
125
|
+
def File rename: old_name to: new_name {
|
126
|
+
"""
|
127
|
+
@old_name Path to @File@ to rename.
|
128
|
+
@new_name Path to new filename.
|
129
|
+
|
130
|
+
Renames a @File@ on the filesystem.
|
131
|
+
"""
|
132
|
+
|
133
|
+
File rename(old_name, new_name)
|
134
|
+
}
|
135
|
+
|
136
|
+
def modes {
|
137
|
+
"""
|
138
|
+
@return @File@ access modes @Array@.
|
139
|
+
|
140
|
+
Returns the @File@ access modes @Array@.
|
141
|
+
"""
|
142
|
+
|
143
|
+
@modes
|
144
|
+
}
|
145
|
+
|
146
|
+
def modes: modes_arr {
|
147
|
+
"""
|
148
|
+
@modes_arr New @File@ access modes @Array@.
|
149
|
+
|
150
|
+
Sets the @File@ access modes @Array@.
|
151
|
+
"""
|
152
|
+
|
153
|
+
@modes = modes_arr
|
154
|
+
}
|
155
|
+
|
156
|
+
def open? {
|
157
|
+
"""
|
158
|
+
@return @true, if @File@ opened, @false otherwise.
|
159
|
+
|
160
|
+
Indicates, if a @File@ is opened.
|
161
|
+
"""
|
162
|
+
|
163
|
+
self closed? not
|
164
|
+
}
|
165
|
+
|
166
|
+
def write: str {
|
167
|
+
"""
|
168
|
+
@str String to be written to a @File@.
|
169
|
+
|
170
|
+
Writes a given @String@ to a @File@.
|
171
|
+
"""
|
172
|
+
|
173
|
+
print(str)
|
174
|
+
}
|
175
|
+
|
176
|
+
def newline {
|
177
|
+
"Writes a newline character to the @File@."
|
178
|
+
|
179
|
+
puts()
|
180
|
+
}
|
181
|
+
|
182
|
+
def directory? {
|
183
|
+
"""
|
184
|
+
@return @true, if @File@ is a @Directory@, @false otherwise.
|
185
|
+
|
186
|
+
Indicates, if a @File@ is a @Directory@.
|
187
|
+
"""
|
188
|
+
|
189
|
+
File directory?(self filename)
|
190
|
+
}
|
191
|
+
}
|
data/lib/rbx/fixnum.fy
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require: "../number"
|
2
|
+
|
3
|
+
class Fixnum {
|
4
|
+
include: Number
|
5
|
+
|
6
|
+
ruby_alias: '==
|
7
|
+
ruby_alias: '-
|
8
|
+
ruby_alias: '+
|
9
|
+
ruby_alias: '*
|
10
|
+
ruby_alias: '/
|
11
|
+
ruby_alias: '<
|
12
|
+
ruby_alias: '>
|
13
|
+
ruby_alias: '<=
|
14
|
+
ruby_alias: '>=
|
15
|
+
ruby_alias: '===
|
16
|
+
ruby_alias: 'chr
|
17
|
+
ruby_alias: 'to_i
|
18
|
+
ruby_alias: '**
|
19
|
+
ruby_alias: '&
|
20
|
+
|
21
|
+
alias_method: 'to_s: for: 'to_s
|
22
|
+
alias_method: 'modulo: for: 'modulo
|
23
|
+
alias_method: ":%" for: "modulo:" # use a : so we dont overwrite ruby's % operator
|
24
|
+
alias_method: 'div: for: 'div
|
25
|
+
}
|
data/lib/rbx/float.fy
ADDED
data/lib/rbx/hash.fy
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Hash {
|
2
|
+
|
3
|
+
alias_method: ":size" for: 'size
|
4
|
+
alias_method: ":[]" for: '[]
|
5
|
+
alias_method: 'at:put: for: "[]="
|
6
|
+
alias_method: 'at: for: '[]
|
7
|
+
ruby_alias: 'keys
|
8
|
+
ruby_alias: 'values
|
9
|
+
|
10
|
+
def inspect {
|
11
|
+
str = "<["
|
12
|
+
max = self size - 1
|
13
|
+
i = 0
|
14
|
+
self each: |key,val| {
|
15
|
+
str = str ++ (key inspect) ++ " => " ++ (val inspect)
|
16
|
+
{ str = str + ", " } if: (i < max)
|
17
|
+
i = i + 1
|
18
|
+
}
|
19
|
+
str = str + "]>"
|
20
|
+
str
|
21
|
+
}
|
22
|
+
|
23
|
+
def each: block {
|
24
|
+
each(&block)
|
25
|
+
}
|
26
|
+
|
27
|
+
def each_key: block {
|
28
|
+
each_key(&block)
|
29
|
+
}
|
30
|
+
|
31
|
+
def each_value: block {
|
32
|
+
each_value(&block)
|
33
|
+
}
|
34
|
+
|
35
|
+
def map: block {
|
36
|
+
map(&block)
|
37
|
+
}
|
38
|
+
}
|