Sha256: bf7293e70b148c4349c7893fd86a6bf7783ccb98b0690b6ce09346523d88840c

Contents?: true

Size: 505 Bytes

Versions: 6

Compression:

Stored size: 505 Bytes

Contents

class Mechanize
  class Page < Mechanize::File
    class Image
      attr_reader :node
      attr_reader :page

      def initialize(node, page)
        @node = node
        @page = page
      end

      def src
        @node['src']
      end

      def url
        case src
        when %r{^https?://}
          src
        else 
          if page.bases[0]
            (page.bases[0].href + src).to_s
          else
            (page.uri + src).to_s
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
aai10-mechanize-2.0.1.0 lib/mechanize/page/image.rb
neocoin-mechanize-2.0.2 lib/mechanize/page/image.rb
mechanize-2.0.1 lib/mechanize/page/image.rb
mechanize-2.0 lib/mechanize/page/image.rb
mechanize-2.0.pre.2 lib/mechanize/page/image.rb
mechanize-2.0.pre.1 lib/mechanize/page/image.rb