rb_lovely 0.6.3 → 0.6.4
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/ext/rb_lovely/container.hpp +1 -3
- data/ext/rb_lovely/package.cpp +1 -1
- data/ext/rb_lovely/ruby_util.hpp +2 -2
- data/ext/rb_lovely/sorted_hash.cpp +3 -3
- data/ext/rb_lovely/sorted_set.cpp +2 -2
- data/yard.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f77c4e7bc0c9011e9fac59b5c509836c1217661
|
4
|
+
data.tar.gz: abeb9c72ab3f9c8a636986fb792639fb922c3409
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 424beddca21eba29ed7e03d7bc61c071d4f29eeced343c4160a0259ef3132249b84b6c29293d27ccb755cb44fd14e4a9f49f0aa053534de9856ba532f5b44068
|
7
|
+
data.tar.gz: 5df6f7524c57ad2b0dbe6753f8b4c4ec6d2f50dfc387a6a0894f43172952bc2cf102c76fa546a266851099302791c9f1292fa361a064da4cb911a66314521a75
|
data/ext/rb_lovely/container.hpp
CHANGED
@@ -5,9 +5,7 @@
|
|
5
5
|
|
6
6
|
namespace rb_lovely {
|
7
7
|
|
8
|
-
|
9
|
-
// for each member.
|
10
|
-
auto toS = [](VALUE val) { return RSTRING_PTR(rb_funcall(val, to_sSym, 0)); };
|
8
|
+
auto rbInspect = [](VALUE val) { return RSTRING_PTR(rb_funcall(val, inspectSym, 0)); };
|
11
9
|
|
12
10
|
}
|
13
11
|
#endif
|
data/ext/rb_lovely/package.cpp
CHANGED
data/ext/rb_lovely/ruby_util.hpp
CHANGED
@@ -7,7 +7,7 @@ namespace rb_lovely {
|
|
7
7
|
extern VALUE rbMod;
|
8
8
|
extern VALUE cmpMethSym;
|
9
9
|
extern VALUE hashEqualitySym;
|
10
|
-
extern VALUE
|
10
|
+
extern VALUE inspectSym;
|
11
11
|
extern VALUE hashSym;
|
12
12
|
extern VALUE callSym;
|
13
13
|
extern VALUE compareSym;
|
@@ -39,7 +39,7 @@ static void initRubyUtil() {
|
|
39
39
|
rbMod = rb_define_module("RbLovely");
|
40
40
|
cmpMethSym = rb_intern("<=>");
|
41
41
|
hashEqualitySym = rb_intern("eql?");
|
42
|
-
|
42
|
+
inspectSym = rb_intern("inspect");
|
43
43
|
hashSym = rb_intern("hash");
|
44
44
|
callSym = rb_intern("call");
|
45
45
|
compareSym = ID2SYM(rb_intern("compare"));
|
@@ -113,7 +113,7 @@ VALUE hashUpdate(VALUE self, VALUE key, VALUE val) {
|
|
113
113
|
hash->container.replace(it, member(hash->compareProc, key, val));
|
114
114
|
else
|
115
115
|
hash->container.insert(member(hash->compareProc, key, val));
|
116
|
-
return
|
116
|
+
return val;
|
117
117
|
}
|
118
118
|
|
119
119
|
VALUE hashReplace(VALUE self, VALUE key, VALUE val) {
|
@@ -163,9 +163,9 @@ VALUE hashToString(VALUE self) {
|
|
163
163
|
if (! hash->container.empty()) {
|
164
164
|
auto& idx = hash->container.get<1>();
|
165
165
|
auto it = idx.begin();
|
166
|
-
str << ' ' <<
|
166
|
+
str << ' ' << rbInspect(it->key) << " => " << rbInspect(it->val);
|
167
167
|
for (++it; it != idx.end(); ++it) {
|
168
|
-
str << ", " <<
|
168
|
+
str << ", " << rbInspect(it->key) << " => " << rbInspect(it->val);
|
169
169
|
}
|
170
170
|
}
|
171
171
|
str << " }";
|
@@ -79,9 +79,9 @@ VALUE setToString(VALUE self) {
|
|
79
79
|
Set* set = rubyCast<Set>(self);
|
80
80
|
if (! set->empty()) {
|
81
81
|
auto it = set->begin();
|
82
|
-
str << ' ' <<
|
82
|
+
str << ' ' << rbInspect(*it);
|
83
83
|
for (++it; it != set->end(); ++it) {
|
84
|
-
str << ", " <<
|
84
|
+
str << ", " << rbInspect(*it);
|
85
85
|
}
|
86
86
|
}
|
87
87
|
str << " }";
|
data/yard.rb
CHANGED
@@ -171,6 +171,21 @@ module RbLovely
|
|
171
171
|
# expect(hash.to_a).to eql [[:b, 1], [:a, 3]]
|
172
172
|
def self.[](*content) ; end
|
173
173
|
|
174
|
+
# Set the value associated with a key. If the key already then it and its value are removed.
|
175
|
+
# @return The value that was passed.
|
176
|
+
# @example
|
177
|
+
# hash = RbLovely::SortedHash.new
|
178
|
+
# hash[:a] = 'yo'
|
179
|
+
def []=(key, value) ; end
|
180
|
+
|
181
|
+
# Set the value associated with a key. If the key already then it and its value are removed.
|
182
|
+
# @return The value that was previously associated with the key or nil if the key was not present in the hash.
|
183
|
+
# @example
|
184
|
+
# hash = RbLovely::SortedHash[:a, 'yi']
|
185
|
+
# expect(hash.replace(:a, 'yo')).to eql('yi')
|
186
|
+
# expect(hash.replace(:b, 'hm')).to eql(nil)
|
187
|
+
def replace(key, value) ; end
|
188
|
+
|
174
189
|
# Delete the value associated with a key.
|
175
190
|
# @return The value associated with the deleted key or nil if the key was not in the hash.
|
176
191
|
# @example
|