Sha256: 662e1ba4b692c4f7c2852a2bf8422741c625246f1e2a04ade99acc562a3f2d75

Contents?: true

Size: 683 Bytes

Versions: 49

Compression:

Stored size: 683 Bytes

Contents

require 'polish_cell_number_checker/version'
require 'yaml'

module PolishCellNumber
  class Checker
    def initialize(phone_no)
      @phone_no = phone_no.clone

      @phone_no.gsub!(/\D/, '')
      @phone_no.gsub!(/^48/, '')

      load_data
      check_number
    end

    def cell_number?
      !@found.empty?
    end

    def operator_name
      @found.keys.first unless @found.empty?
    end

    private

    def load_data
      @data ||= YAML.load_file(File.join(File.dirname(__FILE__), '../yaml/operators.yml'))
    end

    def check_number
      @found = @phone_no =~ /[0-9]{9}/ ? @data.select { |_, pool| pool.find { |e| @phone_no =~ /^#{e}/ } } : []
    end
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
polish_cell_number_checker-0.0.56 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.55 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.54 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.53 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.52 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.51 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.50 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.49 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.48 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.47 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.46 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.45 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.44 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.43 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.42 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.41 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.40 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.39 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.38 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.37 lib/polish_cell_number_checker.rb