rfunk 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rfunk/attribute/attribute.rb +1 -2
- data/lib/rfunk/attribute/attribute_function.rb +11 -0
- data/lib/rfunk/attribute/function.rb +24 -0
- data/lib/rfunk/maybe/none.rb +16 -1
- data/lib/rfunk/maybe/some.rb +14 -0
- data/lib/rfunk/tuple.rb +1 -0
- data/lib/rfunk/version.rb +1 -1
- data/lib/rfunk.rb +2 -1
- metadata +4 -3
- data/lib/rfunk/attribute/variable.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1093410c5b9f09c2d27a51264793c2b018a6591
|
4
|
+
data.tar.gz: 09c356f3da1466a01486c6dc3dc164f392616e5e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af3cf4a13a0a8e29f13879b8d24cbe9dd260c84f28773105cbfc6d484027d0a4c38c96107e7e0976f066c4ed72542d7b9a5ca56b2a5cabf6f6a18cdabfa8adb7
|
7
|
+
data.tar.gz: e7013c2584a0971ea445e798df3c85ea50feec45b061f75a81789c4e33332872c7a406a6960445f262cdfc6c43c9f08f2577fd9c702df4e9ed525f2b930dbd05
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RFunk
|
2
|
+
class Function
|
3
|
+
def initialize
|
4
|
+
@variables = {}
|
5
|
+
end
|
6
|
+
|
7
|
+
def var(options)
|
8
|
+
if options.is_a?(Hash)
|
9
|
+
if variables.empty?
|
10
|
+
self.variables = options
|
11
|
+
else
|
12
|
+
ErrorChecking.new.raise_immutable(options, variables)
|
13
|
+
self.variables = variables.merge(options)
|
14
|
+
end
|
15
|
+
else
|
16
|
+
Some(Some(variables)[options])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_accessor :variables
|
23
|
+
end
|
24
|
+
end
|
data/lib/rfunk/maybe/none.rb
CHANGED
@@ -14,12 +14,27 @@ module RFunk
|
|
14
14
|
self
|
15
15
|
end
|
16
16
|
|
17
|
+
def coerce(other)
|
18
|
+
[other, 0]
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_str
|
22
|
+
''
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_ary
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_hash
|
30
|
+
{}
|
31
|
+
end
|
32
|
+
|
17
33
|
protected
|
18
34
|
|
19
35
|
def enum
|
20
36
|
[]
|
21
37
|
end
|
22
|
-
|
23
38
|
end
|
24
39
|
|
25
40
|
def None(value = nil)
|
data/lib/rfunk/maybe/some.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module RFunk
|
2
2
|
class Some < Option
|
3
|
+
extend Forwardable
|
4
|
+
|
3
5
|
def initialize(value)
|
4
6
|
@value = value
|
5
7
|
end
|
@@ -26,6 +28,18 @@ module RFunk
|
|
26
28
|
value <=> other.value
|
27
29
|
end
|
28
30
|
|
31
|
+
def coerce(other)
|
32
|
+
[other, value]
|
33
|
+
end
|
34
|
+
|
35
|
+
[:to_str, :to_ary, :to_hash].each { |k|
|
36
|
+
define_method(k) {
|
37
|
+
value
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
def_delegators :@value, :to_s, :inspect, :respond_to?
|
42
|
+
|
29
43
|
protected
|
30
44
|
|
31
45
|
def enum
|
data/lib/rfunk/tuple.rb
CHANGED
data/lib/rfunk/version.rb
CHANGED
data/lib/rfunk.rb
CHANGED
@@ -8,7 +8,8 @@ require 'rfunk/attribute/immutable_error'
|
|
8
8
|
require 'rfunk/attribute/attribute_variable'
|
9
9
|
require 'rfunk/attribute/error_checking'
|
10
10
|
require 'rfunk/attribute/attribute_type'
|
11
|
-
require 'rfunk/attribute/
|
11
|
+
require 'rfunk/attribute/function'
|
12
|
+
require 'rfunk/attribute/attribute_function'
|
12
13
|
require 'rfunk/attribute/attribute'
|
13
14
|
require 'rfunk/maybe/option'
|
14
15
|
require 'rfunk/maybe/none'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rfunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Falkowski
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ice_nine
|
@@ -61,13 +61,14 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- lib/rfunk.rb
|
63
63
|
- lib/rfunk/attribute/attribute.rb
|
64
|
+
- lib/rfunk/attribute/attribute_function.rb
|
64
65
|
- lib/rfunk/attribute/attribute_type.rb
|
65
66
|
- lib/rfunk/attribute/attribute_variable.rb
|
66
67
|
- lib/rfunk/attribute/error_checking.rb
|
68
|
+
- lib/rfunk/attribute/function.rb
|
67
69
|
- lib/rfunk/attribute/immutable.rb
|
68
70
|
- lib/rfunk/attribute/immutable_error.rb
|
69
71
|
- lib/rfunk/attribute/not_found_error.rb
|
70
|
-
- lib/rfunk/attribute/variable.rb
|
71
72
|
- lib/rfunk/either/either.rb
|
72
73
|
- lib/rfunk/either/failure.rb
|
73
74
|
- lib/rfunk/either/success.rb
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module RFunk
|
2
|
-
module Variable
|
3
|
-
def var(options)
|
4
|
-
name = "#{self.class.to_s.downcase}_#{caller_locations(1, 1)[0].label}"
|
5
|
-
name = variable_name("#{name}_#{Digest::MD5.hexdigest(name)}")
|
6
|
-
|
7
|
-
if options.is_a?(Hash)
|
8
|
-
variable = self.instance_variable_get(name)
|
9
|
-
|
10
|
-
if variable
|
11
|
-
ErrorChecking.new.raise_immutable(options, variable)
|
12
|
-
self.instance_variable_set(name, variable.merge(options))
|
13
|
-
else
|
14
|
-
self.instance_variable_set(name, options)
|
15
|
-
end
|
16
|
-
else
|
17
|
-
Some(Some(self.instance_variable_get(name))[options])
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|