Browse Source

Small fixes

Piotr Czajkowski 1 year ago
parent
commit
1fe50501f3
2 changed files with 9 additions and 8 deletions
  1. 7 6
      chunkOfSize.go
  2. 2 2
      chunkOfSize_test.go

+ 7 - 6
chunkOfSize.go

@@ -6,7 +6,8 @@ import (
 	"unicode/utf8"
 )
 
-type chunkOfSize struct {
+// ChunkOfSize
+type ChunkOfSize struct {
 	current int
 	limit   int
 	chunks  []string
@@ -14,12 +15,12 @@ type chunkOfSize struct {
 }
 
 // NewChunkOfSize returns new instance of ChunkOfSize initialized with given text and size
-func NewChunkOfSize(text string, size int) *chunkOfSize {
+func NewChunkOfSize(text string, size int) *ChunkOfSize {
 	if utf8.RuneCountInString(text) < size {
 		return nil
 	}
 
-	return &chunkOfSize{
+	return &ChunkOfSize{
 		current: 0,
 		limit:   size,
 		chunks:  strings.Split(text, " "),
@@ -27,7 +28,7 @@ func NewChunkOfSize(text string, size int) *chunkOfSize {
 }
 
 // Next returns next chunk of text or empty string if nothing left to process
-func (c *chunkOfSize) Next() string {
+func (c *ChunkOfSize) Next() string {
 	var b strings.Builder
 	for i := range c.chunks {
 		l := utf8.RuneCountInString(c.chunks[i])
@@ -65,11 +66,11 @@ func (c *chunkOfSize) Next() string {
 }
 
 // Success returns true if there are no errors
-func (c *chunkOfSize) Success() bool {
+func (c *ChunkOfSize) Success() bool {
 	return len(c.errors) == 0
 }
 
 // GetErrors returns erorrs
-func (c *chunkOfSize) GetErrors() []string {
+func (c *ChunkOfSize) GetErrors() []string {
 	return c.errors
 }

+ 2 - 2
chunkOfSize_test.go

@@ -7,8 +7,8 @@ import (
 	"unicode/utf8"
 )
 
-func checkChunks(text string, size int) (*chunkOfSize, int, error) {
-	chunk := NewChunkOfSize(testText, size)
+func checkChunks(text string, size int) (*ChunkOfSize, int, error) {
+	chunk := NewChunkOfSize(text, size)
 	if chunk == nil {
 		return nil, -1, fmt.Errorf("Chunk is nil!")
 	}