URL

URL からディレクトリ名だけを取得する

require 'uri' url = URI.parse('http://ja.wikipedia.org/dir/test/wiki/%E5%BD%B9%E6%89%80%E5%BA%83%E5%8F%B8') path = url.path.sub(/^(\/)/, '') p path.scan(/(.*?)\//) url = URI.parse('http://headlines.yahoo.co.jp/hl') path = url.path.sub(/^(\…