lite-ruby 1.3.0 → 1.3.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/docs/STRUCT.md +0 -25
- data/lib/lite/ruby/struct.rb +1 -9
- data/lib/lite/ruby/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bbae849a2073a389f4e38ff5e8841d572f305c4bdb6a973595eda419c3638b7
|
4
|
+
data.tar.gz: e983d29b4799e2d9c608f680d0dfa93b8f813b9bdaf802860b6a867de4fa4159
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 264c6227410b80819e384fc612c4b3bd7802b5b021563c62027feb3901f9d1e023170639516ca0fde18fbda591d49595426b5e46d495c4a72f3d0680053884c8
|
7
|
+
data.tar.gz: b64b81b77447af8133eae36c57e3295f0073064e1138ec66380ac43410a9b794a59bffa22d4ef6bd00550adfcb9bd532dfaacea66fb2ad9218a07c7197a469f8
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/docs/STRUCT.md
CHANGED
@@ -1,30 +1,5 @@
|
|
1
1
|
# Struct
|
2
2
|
|
3
|
-
`[]`
|
4
|
-
------
|
5
|
-
Access a value in the Struct by key, like a Hash.
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
person = Struct.new(:name, :age)
|
9
|
-
person.new('bob', 60)
|
10
|
-
|
11
|
-
person['name'] #=> 'bob'
|
12
|
-
person['fake'] #=> nil
|
13
|
-
```
|
14
|
-
|
15
|
-
`[]=`
|
16
|
-
------
|
17
|
-
Store a value in the Struct by key, like a Hash.
|
18
|
-
|
19
|
-
```ruby
|
20
|
-
person = Struct.new(:name, :age)
|
21
|
-
person.new('bob', 60)
|
22
|
-
|
23
|
-
person['name'] = 'tim'
|
24
|
-
|
25
|
-
person['name'] #=> 'tim'
|
26
|
-
```
|
27
|
-
|
28
3
|
`attributes`
|
29
4
|
------
|
30
5
|
Returns the key values of the assigned struct.
|
data/lib/lite/ruby/struct.rb
CHANGED
@@ -3,20 +3,12 @@
|
|
3
3
|
if Lite::Ruby.configuration.monkey_patches.include?('struct')
|
4
4
|
class Struct
|
5
5
|
|
6
|
-
def [](key)
|
7
|
-
attributes[key.to_sym]
|
8
|
-
end
|
9
|
-
|
10
|
-
def []=(key, val)
|
11
|
-
send("#{key}=", val)
|
12
|
-
end
|
13
|
-
|
14
6
|
def attributes
|
15
7
|
each_pair.with_object({}) { |(key, val), hash| hash[key] = val }
|
16
8
|
end
|
17
9
|
|
18
10
|
def replace(args)
|
19
|
-
args.each_pair { |key, val|
|
11
|
+
args.each_pair { |key, val| self[key] = val }
|
20
12
|
end
|
21
13
|
|
22
14
|
end
|
data/lib/lite/ruby/version.rb
CHANGED