Module: Helper

Included in:
Codebreaker::Game, Controller, Ui
Defined in:
lib/codebreaker/helper.rb

Overview

This method return value wich match to regular exprassion

Instance Method Summary collapse

Instance Method Details

#to_array(user_input) ⇒ Object



12
13
14
# File 'lib/codebreaker/helper.rb', line 12

def to_array(user_input)
  user_input.split('').map(&:to_i)
end

#verify(params) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/codebreaker/helper.rb', line 3

def verify(params)
  value = gets.strip if params[:value].nil?
  until Regexp.new(params[:matcher]).match(value)
    puts "(!) Please, enter #{params[:message]}"
    value = gets.strip.chomp
  end
  value
end