Sha256: 90d32fa7fc57924150ff0b87884a5031295ec338cad1dbf09152dad8121c57d1

Contents?: true

Size: 500 Bytes

Versions: 4

Compression:

Stored size: 500 Bytes

Contents

class IdsPlease
  class BaseParser

    class << self
      def to_sym
        self.name.split('::').last.downcase.to_sym
      end

      def parse(links)
        links.map do |l|
          id = parse_link(l)
          matched_id = id.match(valid_id_regex) if id
          matched_id[1] if matched_id
        end.compact
      end

      private

      def parse_link(link)
        link.path.split('/')[1]
      end

      def valid_id_regex
        /\A([\w\.\+-]{2,})/
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ids_please-1.1.4 lib/ids_please/base_parser.rb
ids_please-1.1.3 lib/ids_please/base_parser.rb
ids_please-1.1.2 lib/ids_please/base_parser.rb
ids_please-1.1.1 lib/ids_please/base_parser.rb