README.adoc in refinements-8.5.2 vs README.adoc in refinements-9.0.0
- old
+ new
@@ -71,11 +71,10 @@
[source,ruby]
----
require "refinements/arrays"
require "refinements/big_decimals"
-require "refinements/classes"
require "refinements/date_times"
require "refinements/hashes"
require "refinements/ios"
require "refinements/pathnames"
require "refinements/strings"
@@ -92,11 +91,10 @@
[source,ruby]
----
class Example
using Refinements::Arrays
using Refinements::BigDecimals
- using Refinements::Classes
using Refinements::DateTimes
using Refinements::Hashes
using Refinements::IOs
using Refinements::Pathnames
using Refinements::Strings
@@ -260,26 +258,10 @@
[source,ruby]
----
BigDecimal.new("5.0E-10").inspect # "#<BigDecimal:3fd3d458fe84 0.0000000005>"
----
-==== Class
-
-===== #descendants
-
-Answers descendants of a class.
-
-[source,ruby]
-----
-a = Class.new
-b = Class.new a
-c = Class.new a
-
-a.descendants # [b, c]
-Class.new.descendants # []
-----
-
==== DateTime
===== .utc
Answers new DateTime object for current UTC date/time.
@@ -1098,46 +1080,54 @@
Example.with_positions 1 # "#<struct a=1, b=nil, c=nil>"
----
===== #merge
-Merges multiple attributes without mutating itself.
+Merges multiple attributes without mutating itself and supports any object that responds to `#to_h`.
[source,ruby]
----
-Example = Struct.new :a, :b, :c
-example = Example[1, 2, 3]
+other = Struct.new("Other", :a, :b, :c).new 7, 8, 9
+
+example = Struct.new(:a, :b, :c).new 1, 2, 3
example.merge a: 10 # "#<struct a=10, b=2, c=3>"
example.merge a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
example.merge a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
+example.merge {a: 10, b: 20} # "#<struct a=10, b=20, c=3>"
+example.merge other # "#<struct a=7, b=8, c=9>"
example # "#<struct a=1, b=2, c=3>"
-Example = Struct.new :a, :b, :c, keyword_init: true
-example = Example[a: 1, b: 2, c: 3]
+example = Struct.new(:a, :b, :c, keyword_init: true).new a: 1, b: 2, c: 3
example.merge a: 10 # "#<struct a=10, b=2, c=3>"
example.merge a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
+example.merge {a: 10, b: 20} # "#<struct a=10, b=20, c=3>"
+example.merge other # "#<struct a=7, b=8, c=9>"
example.merge a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
example # "#<struct a=1, b=2, c=3>"
----
===== #merge!
-Merges multiple attributes while mutating itself.
+Merges multiple attributes while mutating itself and supports any object that responds to `#to_h`.
[source,ruby]
----
-Example = Struct.new :a, :b, :c
-example = Example[1, 2, 3]
+other = Struct.new("Other", :a, :b, :c).new 7, 8, 9
+
+example = Struct.new(:a, :b, :c).new 1, 2, 3
example.merge! a: 10 # "#<struct a=10, b=2, c=3>"
example.merge! a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
+example.merge! {a: 10, b: 20} # "#<struct a=10, b=20, c=3>"
+example.merge! other # "#<struct a=7, b=8, c=9>"
example.merge! a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
example # "#<struct a=10, b=20, c=30>"
-Example = Struct.new :a, :b, :c, keyword_init: true
-example = Example[a: 1, b: 2, c: 3]
+example = Struct.new(:a, :b, :c, keyword_init: true).new a: 1, b: 2, c: 3
example.merge! a: 10 # "#<struct a=10, b=2, c=3>"
example.merge! a: 10, c: 30 # "#<struct a=10, b=2, c=30>"
+example.merge! {a: 10, b: 20} # "#<struct a=10, b=20, c=3>"
+example.merge! other # "#<struct a=7, b=8, c=9>"
example.merge! a: 10, b: 20, c: 30 # "#<struct a=10, b=20, c=30>"
example # "#<struct a=10, b=20, c=30>"
----
===== #revalue
@@ -1148,19 +1138,16 @@
is constructed using positional or keyword arguments. A positional struct is used in the examples
below but a keyword struct would work too.
[source,ruby]
----
-Example = Struct.new :a, :b, :c
-
-example = Example[1, 2, 3]
+example = Struct.new("Example", :a, :b, :c).new 1, 2, 3
example.revalue { |value| value * 2 } # "#<struct a=2, b=4, c=6>"
example.revalue(c: 2) { |previous, current| previous + current } # "#<struct a=1, b=2, c=5>"
example.revalue c: 2 # "#<struct a=1, b=2, c=3>"
example.revalue # "#<struct a=1, b=2, c=3>"
example # "#<struct a=1, b=2, c=3>"
-
----
===== #revalue!
Transforms values while mutating itself. An optional hash can be supplied to pinpoint and transform
@@ -1256,12 +1243,13 @@
== License
Read link:LICENSE.adoc[LICENSE] for details.
-== History
+== Changes
Read link:CHANGES.adoc[CHANGES] for details.
== Credits
-Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
+* Built with link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
+* Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].