Module: Fancify

Defined in:
lib/fancify.rb,
lib/fancify/version.rb

Constant Summary collapse

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.fancify(word_to_fancify) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/fancify.rb', line 33

def Fancify.fancify(word_to_fancify)
  fancified_word = ''
  word_to_fancify.each_char { |char|
    char_group_id = get_group_id(char)
    fancified_word += get_random_character(char_group_id)
  }
  return fancified_word
end

.get_group_id(character) ⇒ Object



42
43
44
45
46
47
48
49
# File 'lib/fancify.rb', line 42

def Fancify.get_group_id(character)
  $groups.each_with_index {|group, key|
    if(group.include?(character))
      return key
    end
    }
  raise 'Character Not Found'
end

.get_random_character(group_id) ⇒ Object



51
52
53
54
# File 'lib/fancify.rb', line 51

def Fancify.get_random_character(group_id)
  characters_in_group = $groups[group_id]
  return characters_in_group[rand(characters_in_group.length)]
end