mf 0.1.0 → 0.1.1

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
  SHA256:
3
- metadata.gz: a882b64e332d8c2d1e444c4fc33a7054e7dd7878d2ef220131810578bd38752f
4
- data.tar.gz: '0359dee2b216d6bc38c94e985227cc9a12238662289f88fb4faf05c0ff4f06fd'
3
+ metadata.gz: '04692a44951a504a8953c3613d7b0fd9a039acdf75a6f5fdfecc84d3ad582e8c'
4
+ data.tar.gz: dc2eb37ef5a9bfb7f1fafa2f936759d6cdc5f4cd1c43010065791224aebde2ed
5
5
  SHA512:
6
- metadata.gz: 4857eb4340f41ede1680b22397d62c1c883fe9b5cee5aaa9f3cd402dfa8fedf665dafc4117a6c7ff0fd153b9eb42ed0f851c4a76e20058cc618d214de7479eaf
7
- data.tar.gz: da864012d4d60533c292a265671891e3a471a992715262ddac570b79b0f7b2f3191b5571a1f7b487bcc5a161d9b99a4e7f1a4b2901f2c8eefc007a656721e80e
6
+ metadata.gz: bfd353621b03c3619eb584d9050f31b2b808d1fe6ec5ef634c674cf1c4e32297aab54dd2e57067bb0bf5189dff25b79f7dd2d37a91fd81004cb1309b2bb2b64d
7
+ data.tar.gz: 1d9f50437bb951b19b6bd6c12e559834004ca5f6e5fbaac963d30b702266ddf1b87a457e7c212441bab52d8e126f82cc0e19b8ae87fc90c25905c33fb7b1bd56
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- mf (0.1.0)
4
+ mf (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
File without changes
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Mf
2
2
 
3
- Math functions. More of an experiment for now with syntactic sugar operators
3
+ Modifier functions. More of an experiment for now with syntactic sugar operators
4
4
  after an idea occurred:
5
5
 
6
6
  Can Ruby define `self` infix operators and `curry` / `proc`ify them?
@@ -70,6 +70,9 @@ numbers.map(&Mf | 3)
70
70
 
71
71
  numbers.map(&Mf & 3)
72
72
  #=> [1, 2, 3, 0, 1]
73
+
74
+ %w(foo bar baz).map(&Mf[0..1])
75
+ => ["fo", "ba", "ba"]
73
76
  ```
74
77
 
75
78
  ## Installation
@@ -1,28 +1,85 @@
1
1
  module Mf
2
2
  module PublicApi
3
3
  # Math infix operators
4
- def +(b) proc { |a| a + b } end
5
- def -(b) proc { |a| a - b } end
6
- def *(b) proc { |a| a * b } end
7
- def /(b) proc { |a| a / b } end
8
- def %(b) proc { |a| a % b } end
9
- def **(b) proc { |a| a ** b } end
4
+
5
+ def +(b)
6
+ proc { |a| a + b }
7
+ end
8
+
9
+ def -(b)
10
+ proc { |a| a - b }
11
+ end
12
+
13
+ def *(b)
14
+ proc { |a| a * b }
15
+ end
16
+
17
+ def /(b)
18
+ proc { |a| a / b }
19
+ end
20
+
21
+ def %(b)
22
+ proc { |a| a % b }
23
+ end
24
+
25
+ def **(b)
26
+ proc { |a| a ** b }
27
+ end
10
28
 
11
29
  # Comparators
12
- def >(b) proc { |a| a > b } end
13
- def >=(b) proc { |a| a >= b } end
14
- def <(b) proc { |a| a < b } end
15
- def <=(b) proc { |a| a <= b } end
16
- def <=>(b) proc { |a| a <=> b } end
17
- def ==(b) proc { |a| a == b } end
30
+
31
+ def >(b)
32
+ proc { |a| a > b }
33
+ end
34
+
35
+ def >=(b)
36
+ proc { |a| a >= b }
37
+ end
38
+
39
+ def <(b)
40
+ proc { |a| a < b }
41
+ end
42
+
43
+ def <=(b)
44
+ proc { |a| a <= b }
45
+ end
46
+
47
+ def <=>(b)
48
+ proc { |a| a <=> b }
49
+ end
50
+
51
+ def ==(b)
52
+ proc { |a| a == b }
53
+ end
18
54
 
19
55
  # Triple Equals black magic for pre-2.6
20
- def ===(b) proc { |a| b === a } end
56
+
57
+ def ===(b)
58
+ proc { |a| b === a }
59
+ end
21
60
 
22
61
  # Bit Operators
23
- def |(b) proc { |a| a | b } end
24
- def &(b) proc { |a| a & b } end
25
- def >>(b) proc { |a| a >> b } end
26
- def <<(b) proc { |a| a << b } end
62
+
63
+ def |(b)
64
+ proc { |a| a | b }
65
+ end
66
+
67
+ def &(b)
68
+ proc { |a| a & b }
69
+ end
70
+
71
+ def >>(b)
72
+ proc { |a| a >> b }
73
+ end
74
+
75
+ def <<(b)
76
+ proc { |a| a << b }
77
+ end
78
+
79
+ # Bracket Accessors
80
+
81
+ def [](b)
82
+ proc { |a| a[b] }
83
+ end
27
84
  end
28
85
  end
@@ -1,3 +1,3 @@
1
1
  module Mf
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mf
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
  - Brandon Weaver
@@ -93,7 +93,7 @@ files:
93
93
  - CODE_OF_CONDUCT.md
94
94
  - Gemfile
95
95
  - Gemfile.lock
96
- - Guardfile.rb
96
+ - Guardfile
97
97
  - LICENSE.txt
98
98
  - README.md
99
99
  - Rakefile