my_hash_diff 0.0.0
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 +7 -0
- data/lib/my_hash_diff.rb +17 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2ce49c644248ee28e298bab600333b79a42c45668310a93aa88159d655c39adf
|
4
|
+
data.tar.gz: b6dc2a1af56784acf508ec40f56884b33c75f61b47dfb52dc3e1551187120b37
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: be2cc7d1d09ff7c17a602741142015fe0e9f4053c92cb010c67b662093b473aa4474226822677931cb6ea8e625652d2be47114559b68b3e075f1f2dc859fc0e8
|
7
|
+
data.tar.gz: 59b2ddd96197c46486c819d68cb26069fd69553b0d92bda755257c53ad296e834cb8e174461a85f34baddc2483097d7f1f183950dad3925a076fb888a8090a47
|
data/lib/my_hash_diff.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# A ruby gem that will implement the diff algorithm on hash
|
4
|
+
class MyHashDiff
|
5
|
+
def self.calculate(left, right)
|
6
|
+
right.each do |k, v|
|
7
|
+
next if left[k].nil?
|
8
|
+
|
9
|
+
if left[k] == v
|
10
|
+
left.delete(k)
|
11
|
+
else
|
12
|
+
left[k] -= v
|
13
|
+
end
|
14
|
+
end
|
15
|
+
left
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: my_hash_diff
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Andrei Manaila
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-01-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A ruby gem that will implement the diff algorithm on hash
|
14
|
+
email: andreimanaila99@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/my_hash_diff.rb
|
20
|
+
homepage: https://rubygems.org/gems/my_hash_diff
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubygems_version: 3.4.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: ''
|
43
|
+
test_files: []
|