Sha256: fb92cc9602590c9e7ebda800dddcdab31fdbbb5e111127277e826983affe07c6

Contents?: true

Size: 460 Bytes

Versions: 2

Compression:

Stored size: 460 Bytes

Contents

class IdsPlease
  class BaseParser

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

    def self.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 self.parse_link(link)
      link.path.split('/')[1]
    end

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

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ids_please-1.1.0 lib/ids_please/base_parser.rb
ids_please-1.0.6 lib/ids_please/base_parser.rb