Class: Web::SimpleDispatcher::Link
- Defined in:
- lib/web/simpledispatcher.rb
Instance Attribute Summary collapse
-
#page ⇒ Object
readonly
Returns the value of attribute page.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Class Method Summary collapse
Instance Method Summary collapse
- #encode ⇒ Object
- #get_link ⇒ Object
-
#initialize(page, query) ⇒ Link
constructor
A new instance of Link.
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
#page ⇒ Object (readonly)
Returns the value of attribute page.
27 28 29 |
# File 'lib/web/simpledispatcher.rb', line 27 def page @page end |
#query ⇒ Object (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
#encode ⇒ Object
38 39 40 |
# File 'lib/web/simpledispatcher.rb', line 38 def encode encode64(Marshal.dump(self)) end |
#get_link ⇒ Object
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 |