Sha256: b0b8c12aa5a2816cb30a7d1bb96c9ad78a8436ba272633f1ffbb73ad82a277bd

Contents?: true

Size: 945 Bytes

Versions: 4

Compression:

Stored size: 945 Bytes

Contents

require "film_snob/video_site"

class FilmSnob
  class Instagram < VideoSite
    def self.valid_url_patterns
      [
        %r{https?://(?:(?:www).)?instagram.com/p/(\w+)},
        %r{https?://(?:(?:www).)?instagr.am/p/(\w+)}
      ]
    end

    def self.oembed_endpoint
      "http://api.instagram.com/oembed"
    end

    def clean_url
      @clean_url ||= "http://instagram.com/p/#{id}"
    end

    def html
      # instagram's oembed response does not include html,
      # so we need to construct it
      # but first we need to ensure that the response was good
      # which we do by checking for the presence of the title,
      # which will raise an exception if it"s not present
      title && constructed_html
    end

    private

    def constructed_html
      "<iframe src='//instagram.com/p/#{id}/embed/' width='612' height='710' " \
      "frameborder='0' scrolling='no' allowtransparency='true'></iframe>"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
film_snob-0.6.1 lib/film_snob/video_sites/instagram.rb
film_snob-0.6.0 lib/film_snob/video_sites/instagram.rb
film_snob-0.5.0 lib/film_snob/video_sites/instagram.rb
film_snob-0.4.0 lib/film_snob/instagram.rb