Class: Trenni::URI
- Inherits:
-
Object
- Object
- Trenni::URI
- Defined in:
- lib/trenni/uri.rb
Overview
This class is superceeded by ‘Trenni::Reference`.
Instance Attribute Summary collapse
-
#fragment ⇒ Object
readonly
A fragment identifier, the part after the ‘#’.
-
#parameters ⇒ Object
readonly
User supplied parameters that will be appended to the query part.
-
#path ⇒ Object
readonly
The path component of the URI, e.g.
-
#query_string ⇒ Object
readonly
The un-parsed query string of the URI, e.g.
Instance Method Summary collapse
- #append(buffer) ⇒ Object
-
#initialize(path, query_string, fragment, parameters) ⇒ URI
constructor
A new instance of URI.
- #to_str ⇒ Object (also: #to_s)
Constructor Details
#initialize(path, query_string, fragment, parameters) ⇒ URI
Returns a new instance of URI.
26 27 28 29 30 31 |
# File 'lib/trenni/uri.rb', line 26 def initialize(path, query_string, fragment, parameters) @path = path @query_string = query_string @fragment = fragment @parameters = parameters end |
Instance Attribute Details
#fragment ⇒ Object (readonly)
A fragment identifier, the part after the ‘#’
40 41 42 |
# File 'lib/trenni/uri.rb', line 40 def fragment @fragment end |
#parameters ⇒ Object (readonly)
User supplied parameters that will be appended to the query part.
43 44 45 |
# File 'lib/trenni/uri.rb', line 43 def parameters @parameters end |
#path ⇒ Object (readonly)
The path component of the URI, e.g. /foo/bar/index.html
34 35 36 |
# File 'lib/trenni/uri.rb', line 34 def path @path end |
#query_string ⇒ Object (readonly)
The un-parsed query string of the URI, e.g. ‘x=10&y=20’
37 38 39 |
# File 'lib/trenni/uri.rb', line 37 def query_string @query_string end |
Instance Method Details
#append(buffer) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/trenni/uri.rb', line 45 def append(buffer) if @query_string buffer << escape_path(@path) << '?' << query_string buffer << '&' << query_parameters if @parameters else buffer << escape_path(@path) buffer << '?' << query_parameters if @parameters end if @fragment buffer << '#' << escape(@fragment) end return buffer end |
#to_str ⇒ Object Also known as: to_s
61 62 63 |
# File 'lib/trenni/uri.rb', line 61 def to_str append(String.new) end |