Public feed #599954

Stuff

public text v1 · immutable
Raw Edit
·published 2007-07-02 15:10 UTC
rendered paste body
require 'uri'

module Host
  #HOST_RE = //
  # Returns 'true' value if the handler is capable of processing the url
  def handle_url?(u)
    u.host =~ @@HOST_RE
  end
end


class Example
  @@HOST_RE = /example.com$/
  class << self
    include Host
  end

  def self.url2img(u)
    if u.is_a?(string)
      u = URI.parse(u) 
    end
    u.path = '/img' + uri.path + '.jpg'
  end
end


Example.handle_url?(URI.parse('http://www.example.com/6ABA3/')