Class: Build::URI::Absolute
- Inherits:
-
Struct
- Object
- Struct
- Build::URI::Absolute
- Includes:
- Base
- Defined in:
- lib/build/uri/absolute.rb
Constant Summary collapse
- PARSER =
A subset of RFC2396 specifically relevant to path based URIs. We are not interested in generic URIs such as mailto.
%r{\A ((?<scheme>[^:\/?\#]+):) (\/\/ ((?<userinfo>[^\/?\#]+)@)? (?<host>[^\/?\#]*) ) (?<path>[^?\#]*) (\?(?<query>[^\#]*))? (\#(?<fragment>.*))? \z}x.freeze
Instance Attribute Summary collapse
-
#fragment ⇒ Object
Returns the value of attribute fragment.
-
#host ⇒ Object
Returns the value of attribute host.
-
#path ⇒ Object
Returns the value of attribute path.
-
#query ⇒ Object
Returns the value of attribute query.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#userinfo ⇒ Object
Returns the value of attribute userinfo.
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Base
#+, #basename, #dirname, #merge
Instance Attribute Details
#fragment ⇒ Object
Returns the value of attribute fragment
25 26 27 |
# File 'lib/build/uri/absolute.rb', line 25 def fragment @fragment end |
#host ⇒ Object
Returns the value of attribute host
25 26 27 |
# File 'lib/build/uri/absolute.rb', line 25 def host @host end |
#path ⇒ Object
Returns the value of attribute path
25 26 27 |
# File 'lib/build/uri/absolute.rb', line 25 def path @path end |
#query ⇒ Object
Returns the value of attribute query
25 26 27 |
# File 'lib/build/uri/absolute.rb', line 25 def query @query end |
#scheme ⇒ Object
Returns the value of attribute scheme
25 26 27 |
# File 'lib/build/uri/absolute.rb', line 25 def scheme @scheme end |
#userinfo ⇒ Object
Returns the value of attribute userinfo
25 26 27 |
# File 'lib/build/uri/absolute.rb', line 25 def userinfo @userinfo end |
Class Method Details
.parse(string) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/build/uri/absolute.rb', line 80 def self.parse(string) if match = PARSER.match(string) self.new( match[:scheme], match[:userinfo], match[:host], match[:path], match[:query], match[:fragment] ).freeze end end |
Instance Method Details
#absolute? ⇒ Boolean
40 41 42 |
# File 'lib/build/uri/absolute.rb', line 40 def absolute? true end |
#local? ⇒ Boolean
44 45 46 |
# File 'lib/build/uri/absolute.rb', line 44 def local? false end |
#to_s ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/build/uri/absolute.rb', line 48 def to_s buffer = String.new if scheme buffer << scheme << ':' end if host buffer << '//' if userinfo buffer << userinfo << '@' end buffer << host end if path buffer << path end if query buffer << '?' << query end if fragment buffer << '#' << fragment end return buffer end |