Sha256: 76a3132a2ed3907201379e400a39cfaffaed3f32a5f683fb971b7d11cd66a3a2

Contents?: true

Size: 710 Bytes

Versions: 10

Compression:

Stored size: 710 Bytes

Contents

require 'social_parser/provider/base'

module SocialParser
  module Provider
    class Pinterest < Base
      URL_FORMATS = {
        full: /\A((https?)?:\/\/)?(www\.)?pinterest\.(?<domain>(com|jp))\/(?<id>[\w\-\.]+)\/?/i
      }

      def provider
        :pinterest
      end

      def domain
        @domain || 'com'
      end

      def url
        @domain ||= 'com'
        "https://www.pinterest.#{domain}/#{username}"
      end

      private

      def parse_from_url
        URL_FORMATS.values.each do |format|
          m = format.match(url_from_attributes)
          if m
            @domain = m[:domain]
            return m[:id]
          end
        end
        nil
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
social_parser-1.1.0 lib/social_parser/provider/pinterest.rb
social_parser-1.0.8 lib/social_parser/provider/pinterest.rb
social_parser-1.0.7 lib/social_parser/provider/pinterest.rb
social_parser-1.0.6 lib/social_parser/provider/pinterest.rb
social_parser-1.0.5 lib/social_parser/provider/pinterest.rb
social_parser-1.0.4 lib/social_parser/provider/pinterest.rb
social_parser-1.0.3 lib/social_parser/provider/pinterest.rb
social_parser-1.0.2 lib/social_parser/provider/pinterest.rb
social_parser-1.0.1 lib/social_parser/provider/pinterest.rb
social_parser-1.0.0 lib/social_parser/provider/pinterest.rb