Class: BentleyMcIlroy::BlockSequencedText
- Inherits:
-
Object
- Object
- BentleyMcIlroy::BlockSequencedText
- 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
-
#blocks ⇒ Object
readonly
Returns the value of attribute blocks.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text, block_size) ⇒ BlockSequencedText
constructor
A new instance of BlockSequencedText.
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
#blocks ⇒ Object (readonly)
Returns the value of attribute blocks.
22 23 24 |
# File 'lib/bentley_mcilroy.rb', line 22 def blocks @blocks end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
22 23 24 |
# File 'lib/bentley_mcilroy.rb', line 22 def text @text end |