code-ruby 1.5.6 → 1.6.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/docs/precedence.txt +36 -0
- data/lib/code/concerns/shared.rb +33 -6
- data/lib/code/node/if.rb +5 -0
- data/lib/code/object/date.rb +651 -45
- data/lib/code/object/decimal.rb +722 -78
- data/lib/code/object/dictionary.rb +435 -60
- data/lib/code/object/function.rb +4 -3
- data/lib/code/object/global.rb +8 -1
- data/lib/code/object/integer.rb +724 -87
- data/lib/code/object/list.rb +546 -102
- data/lib/code/object/number.rb +8 -0
- data/lib/code/object/parameter.rb +7 -11
- data/lib/code/object/range.rb +5 -0
- data/lib/code/object/string.rb +14 -0
- data/lib/code/object/time.rb +644 -114
- data/lib/code/parser/equal.rb +1 -1
- data/lib/code/parser/equality.rb +5 -4
- data/lib/code/parser/if.rb +7 -2
- data/lib/code/parser/name.rb +56 -8
- data/lib/code/parser/negation.rb +2 -2
- data/lib/code.rb +1 -1
- data/spec/code/object/decimal_spec.rb +0 -1
- data/spec/code/object/http_spec.rb +72 -68
- data/spec/code/object/integer_spec.rb +0 -1
- data/spec/code/parser/if_modifier_spec.rb +2 -2
- data/spec/code_spec.rb +142 -132
- metadata +4 -2
@@ -2,29 +2,25 @@
|
|
2
2
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
|
-
class Parameter <
|
6
|
-
def initialize(*args, **_kargs, &_block)
|
7
|
-
self.raw = Dictionary.new(args.first)
|
8
|
-
end
|
9
|
-
|
5
|
+
class Parameter < Dictionary
|
10
6
|
def code_name
|
11
|
-
String.new(
|
7
|
+
String.new(code_get(:name))
|
12
8
|
end
|
13
9
|
|
14
10
|
def code_regular?
|
15
|
-
Boolean.new(
|
11
|
+
Boolean.new(code_get(:regular?))
|
16
12
|
end
|
17
13
|
|
18
14
|
def code_keyword?
|
19
|
-
Boolean.new(
|
15
|
+
Boolean.new(code_get(:keyword?))
|
20
16
|
end
|
21
17
|
|
22
18
|
def code_regular_splat?
|
23
|
-
Boolean.new(
|
19
|
+
Boolean.new(code_get(:regular_splat?))
|
24
20
|
end
|
25
21
|
|
26
22
|
def code_keyword_splat?
|
27
|
-
Boolean.new(
|
23
|
+
Boolean.new(code_get(:keyword_splat?))
|
28
24
|
end
|
29
25
|
|
30
26
|
def code_required?
|
@@ -36,7 +32,7 @@ class Code
|
|
36
32
|
end
|
37
33
|
|
38
34
|
def code_default
|
39
|
-
|
35
|
+
code_get(:default).to_code
|
40
36
|
end
|
41
37
|
|
42
38
|
def code_evaluate(...)
|
data/lib/code/object/range.rb
CHANGED
@@ -11,6 +11,11 @@ class Code
|
|
11
11
|
@code_right = args.first.code_right
|
12
12
|
@code_options = args.first.code_options
|
13
13
|
@code_exclude_end = args.first.code_exclude_end
|
14
|
+
elsif args.first.is_a?(List)
|
15
|
+
@code_left = args.first.code_first
|
16
|
+
@code_right = args.first.code_last
|
17
|
+
@code_options = Dictionary.new(args.second.presence || kargs)
|
18
|
+
@code_exclude_end = Boolean.new(code_options.code_get(:exclude_end))
|
14
19
|
else
|
15
20
|
@code_left =
|
16
21
|
(args.first.to_code.nothing? ? Integer.new(0) : args.first.to_code)
|
data/lib/code/object/string.rb
CHANGED
@@ -52,6 +52,12 @@ class Code
|
|
52
52
|
when "substitute"
|
53
53
|
sig(args) { [String, String.maybe] }
|
54
54
|
code_substitute(*code_arguments.raw)
|
55
|
+
when "upcase"
|
56
|
+
sig(args)
|
57
|
+
code_upcase
|
58
|
+
when "size"
|
59
|
+
sig(args)
|
60
|
+
code_size
|
55
61
|
else
|
56
62
|
super
|
57
63
|
end
|
@@ -61,6 +67,10 @@ class Code
|
|
61
67
|
String.new(raw.downcase)
|
62
68
|
end
|
63
69
|
|
70
|
+
def code_upcase
|
71
|
+
String.new(raw.upcase)
|
72
|
+
end
|
73
|
+
|
64
74
|
def code_include?(value)
|
65
75
|
code_value = value.to_code
|
66
76
|
Boolean.new(raw.include?(code_value.raw))
|
@@ -104,6 +114,10 @@ class Code
|
|
104
114
|
code_n = Integer.new(1) if code_n.nothing?
|
105
115
|
String.new(raw.first(code_n.raw))
|
106
116
|
end
|
117
|
+
|
118
|
+
def code_size
|
119
|
+
Integer.new(raw.size)
|
120
|
+
end
|
107
121
|
end
|
108
122
|
end
|
109
123
|
end
|