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.36 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.35 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.34 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.33 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.32 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.31 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.30 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.29 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.27 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.26 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.25 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.24 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.23 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.22 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.21 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.20 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.19 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.18 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.17 lib/polish_cell_number_checker.rb
polish_cell_number_checker-0.0.16 lib/polish_cell_number_checker.rb