rb_lovely 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 81e2fd334254b0f4e4583898aec3b6dd84f81e0a
4
- data.tar.gz: 00285bf3cd11e2b69fc919668beda886ee618b5d
3
+ metadata.gz: 0f77c4e7bc0c9011e9fac59b5c509836c1217661
4
+ data.tar.gz: abeb9c72ab3f9c8a636986fb792639fb922c3409
5
5
  SHA512:
6
- metadata.gz: 81555a532701e85a2e4dd0fd2388d895ee2810e07a273f5e039e45373d4476b8be3b3bbcf1d1a8afda11af4c0829ba7f24d28e71fd55efeda70810ea5e5e6add
7
- data.tar.gz: 03117a51cacbb791b7529cd8691c087e0b8c4bb9c47cf95ac1d638731e1f374fc53d979b2992ceb559b75ba74776303c7465c81f02d69f492b8ce55ab639f93f
6
+ metadata.gz: 424beddca21eba29ed7e03d7bc61c071d4f29eeced343c4160a0259ef3132249b84b6c29293d27ccb755cb44fd14e4a9f49f0aa053534de9856ba532f5b44068
7
+ data.tar.gz: 5df6f7524c57ad2b0dbe6753f8b4c4ec6d2f50dfc387a6a0894f43172952bc2cf102c76fa546a266851099302791c9f1292fa361a064da4cb911a66314521a75
@@ -5,9 +5,7 @@
5
5
 
6
6
  namespace rb_lovely {
7
7
 
8
- // TODO: No more toS, provide inspect instead which is what the containers should be using
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
@@ -5,7 +5,7 @@ namespace rb_lovely {
5
5
  VALUE rbMod;
6
6
  VALUE cmpMethSym;
7
7
  VALUE hashEqualitySym;
8
- VALUE to_sSym;
8
+ VALUE inspectSym;
9
9
  VALUE hashSym;
10
10
  VALUE compareSym;
11
11
  VALUE callSym;
@@ -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 to_sSym;
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
- to_sSym = rb_intern("to_s");
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 self;
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 << ' ' << toS(it->key) << " => " << toS(it->val);
166
+ str << ' ' << rbInspect(it->key) << " => " << rbInspect(it->val);
167
167
  for (++it; it != idx.end(); ++it) {
168
- str << ", " << toS(it->key) << " => " << toS(it->val);
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 << ' ' << toS(*it);
82
+ str << ' ' << rbInspect(*it);
83
83
  for (++it; it != set->end(); ++it) {
84
- str << ", " << toS(*it);
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rb_lovely
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Pike