Class: Trenni::Reference
- Inherits:
-
Object
- Object
- Trenni::Reference
- Defined in:
- lib/trenni/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.
27 28 29 30 31 |
# File 'lib/trenni/reference.rb', line 27 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 ‘#’
40 41 42 |
# File 'lib/trenni/reference.rb', line 40 def fragment @fragment end |
#path ⇒ Object (readonly)
The path component of the URI, e.g. /foo/bar/index.html
34 35 36 |
# File 'lib/trenni/reference.rb', line 34 def path @path end |
#query ⇒ Object (readonly)
The query parameters.
37 38 39 |
# File 'lib/trenni/reference.rb', line 37 def query @query end |
Instance Method Details
#append(buffer) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/trenni/reference.rb', line 42 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
56 57 58 |
# File 'lib/trenni/reference.rb', line 56 def to_str append(String.new) end |