idivisor 0.1.0 → 0.1.5

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: bbf56718d363fcd457c4a46d1c920d19e0076525f2910b2be8796da811675396
4
- data.tar.gz: fd52da48a6cb531940954065e5b765de4d81dd33a1c5f28a878399b79fd2b3c8
3
+ metadata.gz: 949393ce9a778d6c778a1055f7692ae9a8d0cd9f97c1d78368d010eeaa1a66e9
4
+ data.tar.gz: 8b105e8923180791a2988d0bbbc040d70a9b49919e8533225b3c9841b972f388
5
5
  SHA512:
6
- metadata.gz: 7e757f7b3a36f808470263b0c78153b637c3f2f333ccc64ec0de9775a4f4af546404df5b66a084137755da156a71ae062ec816faae5c3b43a9beaaa8db3245dd
7
- data.tar.gz: 1bdeb55d82e27d9feaf8f76adbdc1ec008b8154bde167e48d41eda46420ae773ce7da3d847eebfd1cd6561d41fbce29f70fd3c4bc8c90f1e0271c07966a547ec
6
+ metadata.gz: af2d5e7c18b899a362138f0c0efb1488dd21f153295c21d90720f0f0e98ef531169c9ba8fcc37b76459eef736a61032a0183d6353d56d721b8edf17cd6e88596
7
+ data.tar.gz: 7b13ef2a7596f57832972f8b6758c57b6a8f8b0f1a652bd82f5118432427dd7ed228684bc2d9d78062ea57d1b4e3cc79a0d0888845dd8cc56040ff787d6c5470
data/Gemfile CHANGED
@@ -3,5 +3,5 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in divisor.gemspec
4
4
  gemspec
5
5
 
6
- gem "rake", "~> 12.0"
7
- gem "minitest", "~> 5.0"
6
+ gem "rake", ">= 12.0"
7
+ gem "minitest", ">= 5.0"
data/LICENSE.txt CHANGED
@@ -1,21 +1,116 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021 universato
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.
1
+ CC0 1.0 Universal
2
+
3
+ Statement of Purpose
4
+
5
+ The laws of most jurisdictions throughout the world automatically confer
6
+ exclusive Copyright and Related Rights (defined below) upon the creator and
7
+ subsequent owner(s) (each and all, an "owner") of an original work of
8
+ authorship and/or a database (each, a "Work").
9
+
10
+ Certain owners wish to permanently relinquish those rights to a Work for the
11
+ purpose of contributing to a commons of creative, cultural and scientific
12
+ works ("Commons") that the public can reliably and without fear of later
13
+ claims of infringement build upon, modify, incorporate in other works, reuse
14
+ and redistribute as freely as possible in any form whatsoever and for any
15
+ purposes, including without limitation commercial purposes. These owners may
16
+ contribute to the Commons to promote the ideal of a free culture and the
17
+ further production of creative, cultural and scientific works, or to gain
18
+ reputation or greater distribution for their Work in part through the use and
19
+ efforts of others.
20
+
21
+ For these and/or other purposes and motivations, and without any expectation
22
+ of additional consideration or compensation, the person associating CC0 with a
23
+ Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
24
+ and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
25
+ and publicly distribute the Work under its terms, with knowledge of his or her
26
+ Copyright and Related Rights in the Work and the meaning and intended legal
27
+ effect of CC0 on those rights.
28
+
29
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
30
+ protected by copyright and related or neighboring rights ("Copyright and
31
+ Related Rights"). Copyright and Related Rights include, but are not limited
32
+ to, the following:
33
+
34
+ i. the right to reproduce, adapt, distribute, perform, display, communicate,
35
+ and translate a Work;
36
+
37
+ ii. moral rights retained by the original author(s) and/or performer(s);
38
+
39
+ iii. publicity and privacy rights pertaining to a person's image or likeness
40
+ depicted in a Work;
41
+
42
+ iv. rights protecting against unfair competition in regards to a Work,
43
+ subject to the limitations in paragraph 4(a), below;
44
+
45
+ v. rights protecting the extraction, dissemination, use and reuse of data in
46
+ a Work;
47
+
48
+ vi. database rights (such as those arising under Directive 96/9/EC of the
49
+ European Parliament and of the Council of 11 March 1996 on the legal
50
+ protection of databases, and under any national implementation thereof,
51
+ including any amended or successor version of such directive); and
52
+
53
+ vii. other similar, equivalent or corresponding rights throughout the world
54
+ based on applicable law or treaty, and any national implementations thereof.
55
+
56
+ 2. Waiver. To the greatest extent permitted by, but not in contravention of,
57
+ applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
58
+ unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
59
+ and Related Rights and associated claims and causes of action, whether now
60
+ known or unknown (including existing as well as future claims and causes of
61
+ action), in the Work (i) in all territories worldwide, (ii) for the maximum
62
+ duration provided by applicable law or treaty (including future time
63
+ extensions), (iii) in any current or future medium and for any number of
64
+ copies, and (iv) for any purpose whatsoever, including without limitation
65
+ commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
66
+ the Waiver for the benefit of each member of the public at large and to the
67
+ detriment of Affirmer's heirs and successors, fully intending that such Waiver
68
+ shall not be subject to revocation, rescission, cancellation, termination, or
69
+ any other legal or equitable action to disrupt the quiet enjoyment of the Work
70
+ by the public as contemplated by Affirmer's express Statement of Purpose.
71
+
72
+ 3. Public License Fallback. Should any part of the Waiver for any reason be
73
+ judged legally invalid or ineffective under applicable law, then the Waiver
74
+ shall be preserved to the maximum extent permitted taking into account
75
+ Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
76
+ is so judged Affirmer hereby grants to each affected person a royalty-free,
77
+ non transferable, non sublicensable, non exclusive, irrevocable and
78
+ unconditional license to exercise Affirmer's Copyright and Related Rights in
79
+ the Work (i) in all territories worldwide, (ii) for the maximum duration
80
+ provided by applicable law or treaty (including future time extensions), (iii)
81
+ in any current or future medium and for any number of copies, and (iv) for any
82
+ purpose whatsoever, including without limitation commercial, advertising or
83
+ promotional purposes (the "License"). The License shall be deemed effective as
84
+ of the date CC0 was applied by Affirmer to the Work. Should any part of the
85
+ License for any reason be judged legally invalid or ineffective under
86
+ applicable law, such partial invalidity or ineffectiveness shall not
87
+ invalidate the remainder of the License, and in such case Affirmer hereby
88
+ affirms that he or she will not (i) exercise any of his or her remaining
89
+ Copyright and Related Rights in the Work or (ii) assert any associated claims
90
+ and causes of action with respect to the Work, in either case contrary to
91
+ Affirmer's express Statement of Purpose.
92
+
93
+ 4. Limitations and Disclaimers.
94
+
95
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
96
+ surrendered, licensed or otherwise affected by this document.
97
+
98
+ b. Affirmer offers the Work as-is and makes no representations or warranties
99
+ of any kind concerning the Work, express, implied, statutory or otherwise,
100
+ including without limitation warranties of title, merchantability, fitness
101
+ for a particular purpose, non infringement, or the absence of latent or
102
+ other defects, accuracy, or the present or absence of errors, whether or not
103
+ discoverable, all to the greatest extent permissible under applicable law.
104
+
105
+ c. Affirmer disclaims responsibility for clearing rights of other persons
106
+ that may apply to the Work or any use thereof, including without limitation
107
+ any person's Copyright and Related Rights in the Work. Further, Affirmer
108
+ disclaims responsibility for obtaining any necessary consents, permissions
109
+ or other rights required for any use of the Work.
110
+
111
+ d. Affirmer understands and acknowledges that Creative Commons is not a
112
+ party to this document and has no duty or obligation with respect to this
113
+ CC0 or use of the Work.
114
+
115
+ For more information, please see
116
+ <http://creativecommons.org/publicdomain/zero/1.0/>
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Divisor
1
+ # Idivisor
2
2
 
3
- list divisors for integer.
3
+ list divisors for a integer.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,12 +16,12 @@ And then execute:
16
16
 
17
17
  Or install it yourself as:
18
18
 
19
- $ gem install divisor
19
+ $ gem install idivisor
20
20
 
21
21
  ## Usage
22
22
 
23
23
  ```rb
24
- require 'divisor'
24
+ require 'idivisor'
25
25
 
26
26
  p 100.divisors #=> [1, 2, 4, 5, 10, 20, 25, 50, 100]
27
27
  p 100.each_diviror.to_a #=> [1, 2, 4, 5, 10, 20, 25, 50, 100]
@@ -30,6 +30,8 @@ p 100.each_diviror.to_a #=> [1, 2, 4, 5, 10, 20, 25, 50, 100]
30
30
  p 4.has_divisor?(2) #=> true
31
31
  p 4.divisible_by?(3) #=> false
32
32
 
33
+ # 3 is a divisor of 9.
34
+ # 4 is not a divisor of 2
33
35
  p 3.divisor_of?(9) #=> true
34
36
  p 4.divisor_of?(2) #=> false
35
37
  ```
@@ -40,9 +42,13 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
40
42
 
41
43
  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).
42
44
 
45
+ ### test
46
+
47
+ `$ rake test`(`$ rake`) or `$ ruby test/idivisor_test.rb`
48
+
43
49
  ## Contributing
44
50
 
45
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/divisor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/divisor/blob/master/CODE_OF_CONDUCT.md).
51
+ Bug reports and pull requests are welcome on GitHub at https://github.com/universato/idivisor. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/universato/idivisor/blob/master/CODE_OF_CONDUCT.md).
46
52
 
47
53
 
48
54
  ## License
@@ -8,12 +8,12 @@ Gem::Specification.new do |spec|
8
8
 
9
9
  spec.summary = "divisor"
10
10
  spec.description = "divisors, each_divisor, has_divisor?, divisor_of?"
11
- spec.homepage = "https://github.com/universato/divisor"
11
+ spec.homepage = "https://github.com/universato/idivisor"
12
12
  spec.license = "CC0"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = "https://github.com/universato/divisor"
16
+ spec.metadata["source_code_uri"] = "https://github.com/universato/idivisor"
17
17
 
18
18
  # Specify which files should be added to the gem when it is released.
19
19
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
data/lib/idivisor.rb CHANGED
@@ -1,16 +1,25 @@
1
1
  require "idivisor/version"
2
2
 
3
3
  class Integer
4
- def divisible_by?(num)
5
- self % num == 0
4
+
5
+ # Returns +true+ if other integer is a divisor of self integer.
6
+ # 15.divisible_by?(5) #=> true
7
+ # 15.divisible_by?(4) #=> false
8
+ def divisible_by?(other)
9
+ self % other == 0
6
10
  end
7
11
  alias has_divisor? divisible_by?
8
12
 
9
- def divisor_of?(num)
10
- num % self == 0
13
+ # Returns +true+ if self integer is a divisor of other integer.
14
+ # 5.divisor_of?(15) #=> true
15
+ # 4.divisor_of?(15) #=> false
16
+ def divisor_of?(other)
17
+ other % self == 0
11
18
  end
12
19
 
13
- # list positive divisors from positive integer.
20
+ # Returns an array of the divisors of the integer.
21
+ # 15.divisors #=> [1, 3, 5, 15]
22
+ # 16.divisors #=> [1, 2, 4, 8, 16]
14
23
  def divisors
15
24
  n = self # .abs
16
25
  s = Integer.sqrt(n)
@@ -26,6 +35,10 @@ class Integer
26
35
  res1.concat(res2)
27
36
  end
28
37
 
38
+ # list positive divisors from positive integer.
39
+ # 4.each_divisor do |i|
40
+ # puts i
41
+ # end
29
42
  def each_divisor
30
43
  return enum_for(:each_divisor) unless block_given?
31
44
 
@@ -1,3 +1,3 @@
1
1
  module Idivisor
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idivisor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - universato
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-28 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: divisors, each_divisor, has_divisor?, divisor_of?
14
14
  email:
@@ -26,16 +26,16 @@ files:
26
26
  - Rakefile
27
27
  - bin/console
28
28
  - bin/setup
29
- - divisor.gemspec
29
+ - idivisor.gemspec
30
30
  - lib/idivisor.rb
31
31
  - lib/idivisor/version.rb
32
- homepage: https://github.com/universato/divisor
32
+ homepage: https://github.com/universato/idivisor
33
33
  licenses:
34
34
  - CC0
35
35
  metadata:
36
- homepage_uri: https://github.com/universato/divisor
37
- source_code_uri: https://github.com/universato/divisor
38
- post_install_message:
36
+ homepage_uri: https://github.com/universato/idivisor
37
+ source_code_uri: https://github.com/universato/idivisor
38
+ post_install_message:
39
39
  rdoc_options: []
40
40
  require_paths:
41
41
  - lib
@@ -50,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
50
  - !ruby/object:Gem::Version
51
51
  version: '0'
52
52
  requirements: []
53
- rubygems_version: 3.1.2
54
- signing_key:
53
+ rubygems_version: 3.2.11
54
+ signing_key:
55
55
  specification_version: 4
56
56
  summary: divisor
57
57
  test_files: []