array_op_custom 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/LICENSE.txt +21 -0
- data/README.md +75 -0
- data/Rakefile +6 -0
- data/array_op_custom.gemspec +39 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/array_op_custom/version.rb +3 -0
- data/lib/array_op_custom.rb +37 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7f23356fb450d9a074cdb3956314945d059b8f15226ed73d547d5dde44b7b354
|
4
|
+
data.tar.gz: d3f46d2522fdd8b363779e627531530e8bb539f00187384dea215fb09f8c3e92
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b1ad49f5b959e2f7eb22bfc18ef1a58e2f0bf39cad7a9459b8ee71d6c98afbeb6b540da1c2cf6f5907c4cbfa2a52247c9f0c9968690fc60e24c7bc728d824e33
|
7
|
+
data.tar.gz: d9935ec0dd3b34bb384bbbc02541039aef667a4a5a1ae16e28dbb5751008ca174e55d6c603155b0acc89c3eff2fa514ed2445686a2eb010bf7ba9ee818da0d36
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
array_op_custom (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.3)
|
10
|
+
rake (10.5.0)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.0)
|
16
|
+
rspec-support (~> 3.9.0)
|
17
|
+
rspec-expectations (3.9.0)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.0)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.0)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
array_op_custom!
|
30
|
+
bundler (~> 2.0)
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.0)
|
33
|
+
|
34
|
+
BUNDLED WITH
|
35
|
+
2.0.2
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 k-kyg
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
# ArrayOpCustom
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/array_op_custom`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'array_op_custom'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install array_op_custom
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/k-kyg/array_op_custom.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
40
|
+
|
41
|
+
## Sample
|
42
|
+
```ruby
|
43
|
+
[1, 2, 3] + [4, 5, 6]
|
44
|
+
#=> [5, 7, 9]
|
45
|
+
|
46
|
+
[1, 2, 3, 4] + [4, 5, 6]
|
47
|
+
#=> [5, 7, 9, 4]
|
48
|
+
|
49
|
+
[1, 2, 3] + [4, 5, 6, 7]
|
50
|
+
#=> [5, 7, 9]
|
51
|
+
|
52
|
+
[1, 2, 3] * [4, 5, 6]
|
53
|
+
#=> [4, 10, 18]
|
54
|
+
|
55
|
+
[1, 2, 3, 4] * [4, 5, 6]
|
56
|
+
#=> [4, 10, 18, 4]
|
57
|
+
|
58
|
+
[1, 2, 3] * [4, 5, 6, 7]
|
59
|
+
#=> [4, 10, 18]
|
60
|
+
|
61
|
+
[1, 2, 3] - [4, 5, 6]
|
62
|
+
#=> [3, 3, 3]
|
63
|
+
|
64
|
+
[4, 5, 6] - [1, 2, 3]
|
65
|
+
#=> [3, 3, 3]
|
66
|
+
|
67
|
+
[1, 2, 3].to_s
|
68
|
+
#=> ["1", "2", "3"]
|
69
|
+
|
70
|
+
["1", "2", "3"].to_i
|
71
|
+
#=> [1, 2, 3]
|
72
|
+
|
73
|
+
[1, 2, 3].to_h
|
74
|
+
#=> {:"0"=>1, :"1"=>2, :"2"=>3}
|
75
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
lib = File.expand_path("lib", __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "array_op_custom/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "array_op_custom"
|
7
|
+
spec.version = ArrayOpCustom::VERSION
|
8
|
+
spec.authors = ["k-kyg"]
|
9
|
+
spec.email = ["kygkd38@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %Q(custom array's operator)
|
12
|
+
spec.description = <<DESC
|
13
|
+
Custom array's operator
|
14
|
+
"+", "-" and "*".
|
15
|
+
add method
|
16
|
+
to_s, to_i, to_h.
|
17
|
+
DESC
|
18
|
+
spec.homepage = "https://github.com/k-kyg/ruby_array_op_custom"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
22
|
+
|
23
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
# spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
|
25
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
29
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
30
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
31
|
+
end
|
32
|
+
spec.bindir = "exe"
|
33
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
34
|
+
spec.require_paths = ["lib"]
|
35
|
+
|
36
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
37
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
38
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
39
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "array_op_custom"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require "array_op_custom/version"
|
2
|
+
|
3
|
+
module ArrayOpCustom
|
4
|
+
class Error < StandardError; end
|
5
|
+
# Your code goes here...
|
6
|
+
|
7
|
+
end
|
8
|
+
class Array
|
9
|
+
def +(other)
|
10
|
+
self.each_index do |i|
|
11
|
+
self[i] = other[i] ? self[i] + other[i] : self[i]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
def *(other)
|
15
|
+
self.each_index do |i|
|
16
|
+
self[i] = other[i] ? self[i] * other[i] : self[i]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def -(other)
|
20
|
+
self.each_index do |i|
|
21
|
+
self[i] = other[i] ? (self[i] - other[i]).abs : self[i]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
def to_i
|
25
|
+
self.map{|i| i.to_i}
|
26
|
+
end
|
27
|
+
def to_s
|
28
|
+
self.map{|i| i.to_s}
|
29
|
+
end
|
30
|
+
def to_h
|
31
|
+
h = {}
|
32
|
+
self.each_with_index do |a, b|
|
33
|
+
h[b.to_s.to_sym] = a
|
34
|
+
end
|
35
|
+
return h
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: array_op_custom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- k-kyg
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: |
|
56
|
+
Custom array's operator
|
57
|
+
"+", "-" and "*".
|
58
|
+
add method
|
59
|
+
to_s, to_i, to_h.
|
60
|
+
email:
|
61
|
+
- kygkd38@gmail.com
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- ".gitignore"
|
67
|
+
- ".rspec"
|
68
|
+
- ".travis.yml"
|
69
|
+
- Gemfile
|
70
|
+
- Gemfile.lock
|
71
|
+
- LICENSE.txt
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- array_op_custom.gemspec
|
75
|
+
- bin/console
|
76
|
+
- bin/setup
|
77
|
+
- lib/array_op_custom.rb
|
78
|
+
- lib/array_op_custom/version.rb
|
79
|
+
homepage: https://github.com/k-kyg/ruby_array_op_custom
|
80
|
+
licenses:
|
81
|
+
- MIT
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
84
|
+
rdoc_options: []
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.0.3
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: custom array's operator
|
102
|
+
test_files: []
|