Sha256: e03f557056ccb6886fbd16575d3d0cf760470f09a7bdf034641fc9751563916d

Contents?: true

Size: 738 Bytes

Versions: 7

Compression:

Stored size: 738 Bytes

Contents

class LinkOracle
  class LinkData
    attr_reader :parsed_url

    def initialize(parsed_url)
      @parsed_url = parsed_url
    end

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

    def description
      description = og.description || meta.description || body.description
      description.strip if description
    end

    def image_url
      og.image_url || meta.image_url || body.image_url
    end

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

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
link_oracle-0.1.11 lib/link_oracle/link_data.rb
link_oracle-0.1.10 lib/link_oracle/link_data.rb
link_oracle-0.1.9 lib/link_oracle/link_data.rb
link_oracle-0.1.8 lib/link_oracle/link_data.rb
link_oracle-0.1.7 lib/link_oracle/link_data.rb
link_oracle-0.1.6 lib/link_oracle/link_data.rb
link_oracle-0.1.5 lib/link_oracle/link_data.rb