aoc_rb_helpers 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/aoc_rb_helpers/aoc_input.rb +17 -0
- data/lib/aoc_rb_helpers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be89f829468b5e0144844944ec0bd8a96973e45d9200cf32b8b23de30f3a0a4b
|
4
|
+
data.tar.gz: 2619c91954216ba37620673a97bdd3f27b74e47e8094a418444fa317363b5270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd7f615183ca42cd9bc8fcc2febe8a2d688c781dde3cdff9819aae9cd2157e22ac0943c1076c647750ceb1cdd6aee303d80aa86abdf446f7bcc74fdddd3ef9c8
|
7
|
+
data.tar.gz: c0d45da087522c0a1ce92c43b946674c36e79bf1c2cc6d6e1aa65679b5c32b8141235b3dfe663f8c849ef065936725ccbb288fd3745557e432efa09b2087278d
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
7
7
|
## [Unreleased]
|
8
8
|
- No unreleased changes!
|
9
9
|
|
10
|
+
## [0.0.6]
|
11
|
+
### Added
|
12
|
+
- AocInput#single_line - Strips newline characters from single line puzzle inputs
|
13
|
+
|
10
14
|
## [0.0.5]
|
11
15
|
### Added
|
12
16
|
- AocInput#process_each_line - Processes each line of the input data using the provided block
|
@@ -45,7 +49,8 @@ Initial release.
|
|
45
49
|
### Added
|
46
50
|
- Created `AocInput` class with initial helper methods
|
47
51
|
|
48
|
-
[Unreleased]: https://github.com/pacso/aoc_rb_helpers/compare/v0.0.
|
52
|
+
[Unreleased]: https://github.com/pacso/aoc_rb_helpers/compare/v0.0.6...HEAD
|
53
|
+
[0.0.6]: https://github.com/pacso/aoc_rb_helpers/compare/v0.0.5...v0.0.6
|
49
54
|
[0.0.5]: https://github.com/pacso/aoc_rb_helpers/compare/v0.0.4...v0.0.5
|
50
55
|
[0.0.4]: https://github.com/pacso/aoc_rb_helpers/compare/v0.0.3...v0.0.4
|
51
56
|
[0.0.3]: https://github.com/pacso/aoc_rb_helpers/compare/v0.0.2...v0.0.3
|
@@ -22,6 +22,17 @@ class AocInput
|
|
22
22
|
@data ||= @raw_input
|
23
23
|
end
|
24
24
|
|
25
|
+
# Strips newline characters from the data, leaving a single line of input.
|
26
|
+
#
|
27
|
+
# @return [AocInput] self
|
28
|
+
def single_line
|
29
|
+
can_call?(:single_line)
|
30
|
+
@data = data.chomp('')
|
31
|
+
revoke(:multiple_lines)
|
32
|
+
revoke(:single_line)
|
33
|
+
self
|
34
|
+
end
|
35
|
+
|
25
36
|
# Splits the input string into an array of lines.
|
26
37
|
#
|
27
38
|
# This method processes +@data+ by splitting the input string into multiple lines,
|
@@ -30,9 +41,12 @@ class AocInput
|
|
30
41
|
#
|
31
42
|
# @return [AocInput] self
|
32
43
|
def multiple_lines
|
44
|
+
can_call?(:multiple_lines)
|
33
45
|
@data = data.lines(chomp: true)
|
34
46
|
allow(:columns_of_numbers)
|
47
|
+
allow(:process_each_line)
|
35
48
|
revoke(:multiple_lines)
|
49
|
+
revoke(:single_line)
|
36
50
|
self
|
37
51
|
end
|
38
52
|
|
@@ -49,6 +63,7 @@ class AocInput
|
|
49
63
|
# @return [self] the instance itself, for method chaining
|
50
64
|
# @return [Enumerator] if no block is given
|
51
65
|
def process_each_line
|
66
|
+
can_call?(:process_each_line, "call .multiple_lines first")
|
52
67
|
return to_enum(__callee__) unless block_given?
|
53
68
|
@data = @data.map do |line|
|
54
69
|
yield line
|
@@ -118,6 +133,8 @@ class AocInput
|
|
118
133
|
@can_call = {
|
119
134
|
columns_of_numbers: false,
|
120
135
|
multiple_lines: true,
|
136
|
+
process_each_line: false,
|
137
|
+
single_line: true,
|
121
138
|
sort_arrays: false,
|
122
139
|
transpose: false
|
123
140
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aoc_rb_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Pascoe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-12-
|
11
|
+
date: 2024-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aoc_rb
|