aoc_rb_helpers 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1990cde2622df33946ce6131918c215ac548d3b013ed36b57fd980fd0ba7c0ab
4
- data.tar.gz: 7070a8add7b5f3bf0b4fa033959ce30624edeac87329a95964e2bade9dbb5741
3
+ metadata.gz: be89f829468b5e0144844944ec0bd8a96973e45d9200cf32b8b23de30f3a0a4b
4
+ data.tar.gz: 2619c91954216ba37620673a97bdd3f27b74e47e8094a418444fa317363b5270
5
5
  SHA512:
6
- metadata.gz: 402844433642a9dcfd4bcded006ec9eca2d3cc8b18a0016b7d3cc45631b24e54e37315af3cff1d895c511233a167b9cc82ed21f7f942f721cafe016f8ea552d6
7
- data.tar.gz: 34f664b1de9a6fd751241afc34445c46cc16ab6cce24f246476799d7915ce4f519f4ac67d22a42b72780c673d5c21fe693c19c42786a23f6b529c19beffa53f8
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.5...HEAD
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
  }
@@ -1,3 +1,3 @@
1
1
  module AocRbHelpers
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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.5
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-08 00:00:00.000000000 Z
11
+ date: 2024-12-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aoc_rb