Sha256: dfa97c623497a7954f7ca4ea3eb6607e877fe988dd880251d9a923099a5a65a2
Contents?: true
Size: 393 Bytes
Versions: 4
Compression:
Stored size: 393 Bytes
Contents
require 'iconv' module Lunar class Words < Array SEPARATOR = /\s+/ def initialize(str) words = str.split(SEPARATOR). reject { |w| w.to_s.strip.empty? }. map { |w| sanitize(w) } super(words) end private def sanitize(str) Iconv.iconv('UTF-8//IGNORE', 'UTF-8', str)[0].to_s. gsub(/[^a-zA-Z0-9\-_]/, '') end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
lunar-0.2.2 | lib/lunar/words.rb |
lunar-0.2.1 | lib/lunar/words.rb |
lunar-0.2.0 | lib/lunar/words.rb |
lunar-0.1.1 | lib/lunar/words.rb |