Class: BentleyMcIlroy::BlockSequencedText

Inherits:
Object
  • Object
show all
Defined in:
lib/bentley_mcilroy.rb

Overview

A container for the original text we’re processing. Divides the text into Block objects.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, block_size) ⇒ BlockSequencedText

Returns a new instance of BlockSequencedText.



24
25
26
27
28
29
30
31
32
33
# File 'lib/bentley_mcilroy.rb', line 24

def initialize(text, block_size)
  @text = text
  @block_size = block_size
  @blocks = []

  # "onetwothree" -> ["one", "two", "thr", "ee"]
  @text.scan(/.(?:.?){#{@block_size-1}}/).each.with_index do |text_block, index|
    @blocks << Block.new(text_block, index * @block_size)
  end
end

Instance Attribute Details

#blocksObject (readonly)

Returns the value of attribute blocks.



22
23
24
# File 'lib/bentley_mcilroy.rb', line 22

def blocks
  @blocks
end

#textObject (readonly)

Returns the value of attribute text.



22
23
24
# File 'lib/bentley_mcilroy.rb', line 22

def text
  @text
end