of 0.2.0 → 0.3.0

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: b6c9ce3391b68d1947f267beb2e5be450b1bbc9c
4
- data.tar.gz: 974cfd0d79c121f034dabf607c64b3cd78f20130
3
+ metadata.gz: 499b04d6aab178e1c40380ce36e94152c0c6a074
4
+ data.tar.gz: 3e041852cff83be3fac8bb115ca9bcbac39622c6
5
5
  SHA512:
6
- metadata.gz: a17ad37feb1cae0838039dcbbad917787b9a73e4a7c43d9b839e548fa181c3b26dda17ed795a08f7d7652d905882a2b01fd7f30a4a928109b95846ae64eee440
7
- data.tar.gz: cbd70ba31e39bba76a5a89de6aadd57f1798b973591d18b903af32676c68edd4853090d88be9567c7255168384d64dc9bdcf6dbad4b8543f58d49fadb24deb25
6
+ metadata.gz: 8f902ff86405777e99a35654be69599c6c834fe5850d487c7a377cef04009786e1ba412ec7fdb4a0d0f616c1a7d43837f99a181c307ace0a473fe8c1407589fe
7
+ data.tar.gz: ad0d6cbc858203c5375465cff30cbe747ad467678b4d19156581c13073d492030dda843d770e63f1401daa90d4418a1628ff336eae6df5c3ec603a12800e645d
data/README.md CHANGED
@@ -21,12 +21,21 @@ $ gem install of
21
21
  ```
22
22
 
23
23
  ## Basic Usage
24
+
25
+ ### Block Syntax
24
26
  ```ruby
25
27
  def 7_of_9
26
28
  7.of { 9 } # => [9, 9, 9, 9, 9, 9, 9, 9]
27
29
  end
28
30
  ```
29
31
 
32
+ ### Class Syntax
33
+ ```ruby
34
+ def 3_objects
35
+ 3.of(Object) # => [#<Object:0x007fb0db8b75c0>, #<Object:0x007fb0db8b7548>, #<Object:0x007fb0db8b74f8>]
36
+ end
37
+ ```
38
+
30
39
  ## Usage with Refinements
31
40
  ```ruby
32
41
  class MyClass
data/lib/of/method.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  module Of
2
2
  METHOD = proc do
3
- def of(&block)
3
+ def of(klass=nil, &block)
4
+ klass || block || raise(ArgumentError, 'must provide a `Class` or block')
5
+ block || klass.respond_to?(:new) || raise(ArgumentError, 'class must respond to `.new`')
6
+ block = proc { klass.new } if klass.is_a? Class
4
7
  self.times.map(&block)
5
8
  end
6
9
  end
data/lib/of/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Of
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: of
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Waldrip