lib/hook/hookapp.rb
# Check if format fully matches or matches the first
# character of available options.
# Return full valid format or nil
Check if format fully matches or matches the first
character of available options.
Return full valid format or nil
Check if format fully matches or matches the first character of available options . Return full valid format or nil
def validate_format(fmt, options)
    valid_format_rx = options.map { |format| format.sub(/^(.)(.*)$/, '^\1(\2)?$') }
    valid_format = nil
    valid_format_rx.each_with_index do |rx, i|
      cmp = Regexp.new(rx, 'i')
      next unless fmt =~ cmp
      valid_format = options[i]
      break
    end
    valid_format
  end
def validate_format ( fmt , options ) valid_format_rx = options . map { | format | format . sub ( / ^(.)(.*)$ / , '^\1(\2)?$' ) } valid_format = nil valid_format_rx . each_with_index do | rx , i | cmp = Regexp . new ( rx , 'i' ) next unless fmt =~ cmp valid_format = options [ i ] break end valid_format end
Check if format fully matches or matches the first
character of available options.
Check if format fully matches or matches the first character of available options .
fmt
<not_specific>
options
<not_specific>