Class: XRB::Reference
- Inherits:
-
Object
- Object
- XRB::Reference
- Defined in:
- lib/xrb/reference.rb
Instance Attribute Summary collapse
-
#fragment ⇒ Object
readonly
A fragment identifier, the part after the ‘#’.
-
#path ⇒ Object
readonly
The path component of the URI, e.g.
-
#query ⇒ Object
readonly
The query parameters.
Instance Method Summary collapse
- #append(buffer) ⇒ Object
-
#initialize(path, query = {}, fragment: nil) ⇒ Reference
constructor
A new instance of Reference.
- #to_str ⇒ Object (also: #to_s)
Constructor Details
#initialize(path, query = {}, fragment: nil) ⇒ Reference
Returns a new instance of Reference.
10 11 12 13 14 |
# File 'lib/xrb/reference.rb', line 10 def initialize(path, query = {}, fragment: nil) @path = path.to_s @query = query @fragment = fragment end |
Instance Attribute Details
#fragment ⇒ Object (readonly)
A fragment identifier, the part after the ‘#’
23 24 25 |
# File 'lib/xrb/reference.rb', line 23 def fragment @fragment end |
#path ⇒ Object (readonly)
The path component of the URI, e.g. /foo/bar/index.html
17 18 19 |
# File 'lib/xrb/reference.rb', line 17 def path @path end |
#query ⇒ Object (readonly)
The query parameters.
20 21 22 |
# File 'lib/xrb/reference.rb', line 20 def query @query end |
Instance Method Details
#append(buffer) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/xrb/reference.rb', line 25 def append(buffer) buffer << escape_path(@path) unless @query.empty? buffer << "?" << query_string end if @fragment buffer << "#" << escape(@fragment) end return buffer end |
#to_str ⇒ Object Also known as: to_s
39 40 41 |
# File 'lib/xrb/reference.rb', line 39 def to_str append(String.new) end |