emittance 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5aa08e8db74f9be24f08a38983291c67293c204e
4
- data.tar.gz: 738f991042e17d4414fc491bdf74df4360801f30
3
+ metadata.gz: 1fb073480e93c98fa14f649645d6c9c50d026288
4
+ data.tar.gz: 2189f09a861ba518cc4887b4ab888ee9eec2abbe
5
5
  SHA512:
6
- metadata.gz: 86045a1315babc710189b66ddde7e800ff830048c3bbcd954469adb915d689ebcd4d3dea42dc91a2ceca3c5e3932da5c260bb955c8381b02342e97a1579cfabc
7
- data.tar.gz: ec7772819f3e6e0e47a367667b2fb986547ebe293a1ccb5a318eaf05ac279f2bb480f6d66e30c172f1de92ea1f966e0096f7cb438d838cebcafe7f21489a55ef
6
+ metadata.gz: 181e8a6a597a8684be6dab5d03e4651b42969b6fd168c121307309e8e0334e9eecd2817db78855e9efc13bb0a3e64f2e8e58043e5ce17d15d251eb89ec2dd822
7
+ data.tar.gz: 1ffd3a6302f02a11ea975b6d1d19ced771b967ae20905969ea355d62b9cc5bd161ef503e6a66387e4d087b1d5be49c3865a136c4229b7092b0696d03a320d6ba
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- emittance (0.1.0)
4
+ emittance (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -17,7 +17,6 @@ module Emittance
17
17
  # @param blk block passed to +Array#each+
18
18
  # @return [RegistrationCollectionProxy] self
19
19
  def each(*args, &blk)
20
- arrays = mappings.values.map(&:to_a)
21
20
  arrays.flatten.each(*args, &blk)
22
21
  self
23
22
  end
@@ -27,6 +26,30 @@ module Emittance
27
26
  mappings.values.all?(&:empty?)
28
27
  end
29
28
 
29
+ # @return [Integer] the number of registrations that exist in the collection
30
+ def length
31
+ arrays.flatten.length
32
+ end
33
+
34
+ alias size length
35
+ alias count length
36
+
37
+ # @param idx [Integer] the index you wish to find
38
+ # @return the registration indexed at the specified index
39
+ def [](idx)
40
+ arrays.flatten[idx]
41
+ end
42
+
43
+ # @return the registration at the first index
44
+ def first
45
+ self[0]
46
+ end
47
+
48
+ # @return the registration at the last index
49
+ def last
50
+ self[-1]
51
+ end
52
+
30
53
  # @return [RegistrationCollectionProxy] self
31
54
  def <<(item)
32
55
  mappings[lookup_term] << item
@@ -42,6 +65,10 @@ module Emittance
42
65
  private
43
66
 
44
67
  attr_reader :lookup_term, :mappings
68
+
69
+ def arrays
70
+ mappings.values.map(&:to_a)
71
+ end
45
72
  end
46
73
  end
47
74
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emittance
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emittance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tyler Guillen