Module: AM::Validate

Includes:
MessageControl
Included in:
CLI, Ui
Defined in:
lib/validate.rb

Constant Summary

Constants included from MessageControl

MessageControl::ERROR_MESSAGE, MessageControl::NOTICE_MESSAGE, MessageControl::WARNING_MESSAGE

Instance Method Summary collapse

Methods included from MessageControl

#after_sepalate, #before_sepalate, #error, #notice, #print_message, #warning

Instance Method Details

#uniq?(new_alias) ⇒ Boolean

Returns:

  • (Boolean)


7
8
9
10
11
12
13
14
15
16
17
# File 'lib/validate.rb', line 7

def uniq?(new_alias)
  ak,av = new_alias.first
  @config.al.each do |k,v|
    if ak == k
      error(:duplicate_alias, ak)
    elsif av == v
      error(:duplicate_command, av)
    end
  end
  true
end

#valid?(val, pattern) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/validate.rb', line 19

def valid?(val, pattern)
  /#{pattern}/ =~ val && val.to_s.length != 0
end