Sha256: f1141940048bef289d8d7db41a2098e1506af130ee2925c5f54b4d4a533c69cb

Contents?: true

Size: 747 Bytes

Versions: 8

Compression:

Stored size: 747 Bytes

Contents

class LinkOracle
  class LinkData
    attr_reader :parsed_data, :url

    def initialize(parsed_url)
      @parsed_data = parsed_url[:parsed_data]
      @url = parsed_url[:url]
    end

    #TODO: Need to write tests for these
    def title
      og.title || meta.title || body.title
    end

    def description
      og.description || meta.description|| body.description
    end

    def image_url
      Utils::ImageUrlFormatter.new(url, og.image_url || meta.image_url || body.image_url).perform
    end

    def og
      @og ||= Extractor::OG.new(parsed_data).perform
    end

    def meta
      @meta ||= Extractor::Meta.new(parsed_data).perform
    end

    def body
      @body ||= Extractor::Body.new(parsed_data).perform
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
link_oracle-0.1.2 lib/link_oracle/link_data.rb
link_oracle-0.1.1 lib/link_oracle/link_data.rb
link_oracle-0.1.0 lib/link_oracle/link_data.rb
link_oracle-0.0.8 lib/link_oracle/link_data.rb
link_oracle-0.0.7 lib/link_oracle/link_data.rb
link_oracle-0.0.6 lib/link_oracle/link_data.rb
link_oracle-0.0.5 lib/link_oracle/link_data.rb
link_oracle-0.0.4 lib/link_oracle/link_data.rb