class ArticleFixtureGen::Data::BuildWordList::EntriesForStringItem

Build an arary of WordEntry instances for “words” in a “string item”.

Attributes

position[R]
word_index[R]
words[R]

Public Class Methods

call(string_item:) click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 106
def self.call(string_item:)
  EntriesForStringItem.new(string_item).call
end
new(string_item) click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 116
def initialize(string_item)
  @position = string_item.position
  @word_index = 0
  @words = string_item.string.split
  self
end

Public Instance Methods

call() click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 110
def call
  words.map { |word| entry_for word }
end

Private Instance Methods

entry_for(word) click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 127
def entry_for(word)
  ret = WordEntry.new entry_params_for(word)
  @word_index += 1
  ret
end
entry_params_for(word) click to toggle source
# File lib/article_fixture_gen/data/build_word_list.rb, line 133
def entry_params_for(word)
  { dom_position: position, word: word, word_index: word_index }
end