class Milkode::Mkurl

Public Class Methods

new(path, params) click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 12
def initialize(path, params)
  @path = escape_path(path)
  @params = params
end

Public Instance Methods

inherit_query_shead() click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 21
def inherit_query_shead
  create_url(query_param(true, true, false))
end
inherit_query_shead_offset() click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 17
def inherit_query_shead_offset
  create_url(query_param(true, true, true))
end
inherit_query_shead_set_sort(sort_kind) click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 25
def inherit_query_shead_set_sort(sort_kind)
  create_url(query_param(true, true, false, sort_kind))
end
inherit_shead() click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 33
def inherit_shead
  create_url(query_param(false, true, false))
end

Private Instance Methods

create_url(qp) click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 48
def create_url(qp)
  if (qp == "")
    @path
  else
    "#{@path}?#{qp}"
  end
end
escape(src) click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 44
def escape(src)
  Rack::Utils::escape(src)
end
escape_path(src) click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 39
def escape_path(src)
  # /rack-1.3.0/lib/rack/utils.rb:29
  Rack::Utils::escape_path(src).gsub("%2F", '/')
end
query_param(query_inherit, shead_inherit, offset_inherit, sort_kind = nil) click to toggle source
# File lib/milkode/cdweb/lib/mkurl.rb, line 56
def query_param(query_inherit, shead_inherit, offset_inherit, sort_kind = nil)
  qparam = []
  qparam << "query=#{escape(@params[:query])}" if (query_inherit and @params[:query])
  qparam << "shead=#{escape(@params[:shead])}" if (shead_inherit and @params[:shead])
  qparam << "onematch=#{escape(@params[:onematch])}" if (shead_inherit and @params[:onematch])
  qparam << "sensitive=#{escape(@params[:sensitive])}" if (shead_inherit and @params[:sensitive])
  qparam << "offset=#{escape(@params[:offset])}" if (offset_inherit and @params[:offset])
  qparam << "line=#{escape(@params[:line])}" if (offset_inherit and @params[:line])
  qparam << "sort=#{sort_kind}" if sort_kind
  qparam.join('&')
end