Class: Sifar

Inherits:
Object
  • Object
show all
Defined in:
lib/sifar.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}, error_messages = {}) ⇒ Sifar

Returns a new instance of Sifar.



8
9
10
# File 'lib/sifar.rb', line 8

def initialize(options = {}, error_messages = {})
  set_opt options, error_messages
end

Instance Attribute Details

#errorsObject

Returns the value of attribute errors.



6
7
8
# File 'lib/sifar.rb', line 6

def errors
  @errors
end

Instance Method Details

#check(word) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/sifar.rb', line 12

def check(word)
  @errors = []

  check_length(word) unless @options[:minimum_length].nil?
  check_dictionary(word) unless @options[:dictionary].nil?
  check_character_blacklist(word) unless @options[:character_blacklist].nil?
  check_phonetic(word, @options[:name]) unless @options[:phonetic_similarity].nil?
  check_similarity(word, @options[:name]) unless @options[:similarity].nil?

  check_heterogeneity(word) if true == @options[:heterogeneous]

  1 > @errors.length
end

#generateObject



26
27
28
29
30
31
32
33
# File 'lib/sifar.rb', line 26

def generate
  n = 0
  begin
    n += 1
    word = create
  end until true == check(word)
  word
end