Class: Sifar
- Inherits:
-
Object
- Object
- Sifar
- Defined in:
- lib/sifar.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
Instance Method Summary collapse
- #check(word) ⇒ Object
- #generate ⇒ Object
-
#initialize(options = {}, error_messages = {}) ⇒ Sifar
constructor
A new instance of Sifar.
Constructor Details
#initialize(options = {}, error_messages = {}) ⇒ Sifar
Returns a new instance of Sifar.
8 9 10 |
# File 'lib/sifar.rb', line 8 def initialize( = {}, = {}) set_opt , end |
Instance Attribute Details
#errors ⇒ Object
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 |
#generate ⇒ Object
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 |