class Tomereader::Phrase

Attributes

words[R]

include Settings

Public Class Methods

new(phrase_string) click to toggle source
# File lib/tomereader/phrase.rb, line 5
def initialize(phrase_string)
  @phrase_string = phrase_string.strip
  @word_pattern = /[\s,;\"\—]+/
  @words = []
  #@logger = create_logger
end

Public Instance Methods

split() { |word_string, position| ... } click to toggle source

split phrase into words @return Array of words

# File lib/tomereader/phrase.rb, line 19
def split
  return false if words.count > 0
  begin
    word_strings.each_with_index do |word_string, position|
      word = yield(word_string, position)
      @words << word if word.is_a? Word
    end
    words.count
  rescue => e
    #@logger.warn e.message
  end
end
to_s() click to toggle source
# File lib/tomereader/phrase.rb, line 11
def to_s
  @phrase_string
end
word_strings() click to toggle source
# File lib/tomereader/phrase.rb, line 14
def word_strings
  @phrase_string.split @word_pattern
end