Class: Web::SimpleDispatcher::Link

Inherits:
Object
  • Object
show all
Defined in:
lib/web/simpledispatcher.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(page, query) ⇒ Link

Returns a new instance of Link.



29
30
31
32
# File 'lib/web/simpledispatcher.rb', line 29

def initialize page, query
		@page = page
		@query = query
end

Instance Attribute Details

#pageObject (readonly)

Returns the value of attribute page.



27
28
29
# File 'lib/web/simpledispatcher.rb', line 27

def page
  @page
end

#queryObject (readonly)

Returns the value of attribute query.



27
28
29
# File 'lib/web/simpledispatcher.rb', line 27

def query
  @query
end

Class Method Details

.make_query_string(query) ⇒ Object



43
44
45
46
47
# File 'lib/web/simpledispatcher.rb', line 43

def make_query_string query
    query.collect do |k,v|
	"#{k}=#{Web.escape(v)}"
    end.join("&")
end

.unencode(string) ⇒ Object



49
50
51
# File 'lib/web/simpledispatcher.rb', line 49

def Link.unencode string
    Marshal.load(decode64(string))
end

Instance Method Details

#encodeObject



38
39
40
# File 'lib/web/simpledispatcher.rb', line 38

def encode
		encode64(Marshal.dump(self))
end


34
35
36
# File 'lib/web/simpledispatcher.rb', line 34

def get_link
		"#{SimpleDispatcher.template_from_class(@page)}?#{Link.make_query_string(Web.encode_objects(@query))}"
end