character_enumerator 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/character_enumerator.rb +34 -0
- data/lib/character_enumerator/version.rb +3 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2e34e411f940ad6241d49bd8a42871699eddb62895eb2c6d9ecaf4029fca646c
|
4
|
+
data.tar.gz: 888953fea926bdbcb9e4a2ec1cbeb954e11640639f8bfb417d777b859301ac17
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7d6119e25ae6c66830f6240ce746e585d37cba26f6f1516cf0c7eb88fc97d303ac639a40b78cb9c5141adaf3b8f13a4da4c8fba7345af38e65d8576b82888e29
|
7
|
+
data.tar.gz: 991d0d160cfa89d2724b2dd643fde9881812a5a8bc953dbabf1949665064fa58d850b7771e989edf035fdea7229c0c5bc902d77928f2a15549d10a542773e9e2
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "character_enumerator/version"
|
2
|
+
|
3
|
+
module CharacterEnumerator
|
4
|
+
module Implementation
|
5
|
+
def generate(size)
|
6
|
+
Enumerator.new(size) do |y|
|
7
|
+
size.times do |index|
|
8
|
+
y << internal_integer_to_characters(index)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def integer_to_characters(value)
|
14
|
+
raise ArgumentError, "Value must be integer" unless value.is_a?(Integer)
|
15
|
+
raise ArgumentError, "Value must be non-negative integer" if value < 0
|
16
|
+
internal_integer_to_characters(value)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def internal_integer_to_characters(value)
|
22
|
+
result = []
|
23
|
+
dividend = value + 1
|
24
|
+
while dividend > 0
|
25
|
+
modulo = (dividend - 1) % 26
|
26
|
+
result.unshift(65 + modulo)
|
27
|
+
dividend = (dividend - modulo) / 26
|
28
|
+
end
|
29
|
+
result.pack("C*")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
extend Implementation
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: character_enumerator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Krists Ozols
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-12 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: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- krists.ozols@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/character_enumerator.rb
|
63
|
+
- lib/character_enumerator/version.rb
|
64
|
+
homepage: https://github.com/krists/character_enumerator
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata:
|
68
|
+
homepage_uri: https://github.com/krists/character_enumerator
|
69
|
+
source_code_uri: https://github.com/krists/character_enumerator
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '2.4'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubygems_version: 3.0.3
|
86
|
+
signing_key:
|
87
|
+
specification_version: 4
|
88
|
+
summary: Ruby enumerator that converts integers to character representation(Like in
|
89
|
+
Microsoft Excel - A, B, C, .. Z, AA, AB)
|
90
|
+
test_files: []
|