Sha256: daede313b90f287119d86c90288234f057796e4cf83f6eac01c76b858fc41829
Contents?: true
Size: 805 Bytes
Versions: 1
Compression:
Stored size: 805 Bytes
Contents
module Sastrawi module Dictionary class ArrayDictionary attr_reader :words def initialize(words = []) @words = [] add_words(words) end def contains?(word) @words.include?(word) end def count @words.length end def add_words(new_words) new_words.each do |word| add(word) end end def add(word) return if word == '' @words.push(word) end def add_words_from_text_file(file_path) words = [] File.open(file_path, 'r') do |file| file.each do |line| words.push(line.chomp) end end add_words(words) end def remove(word) @words.delete(word) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sastrawi-0.1.0 | lib/sastrawi/dictionary/array_dictionary.rb |