class Nknm::Nickname

Attributes

text[R]
to_s[R]

Public Class Methods

new(text) click to toggle source
# File lib/nknm/nickname.rb, line 8
def initialize(text)
  @text = text
end

Public Instance Methods

for?(word) click to toggle source

Is this nickname suitable for the specified word? @param word [String] @return [Boolean]

# File lib/nknm/nickname.rb, line 15
def for?(word)
  regex.match?(word)
end

Private Instance Methods

regex() click to toggle source
# File lib/nknm/nickname.rb, line 21
def regex
  @_regex ||= Regexp.compile("^#{(text || "").to_s.downcase.chars.join(".*")}")
end