Class: URI::Acct
- Inherits:
-
Generic
- Object
- Generic
- URI::Acct
- Defined in:
- lib/bridgetown/webfinger/uri/acct.rb
Overview
A URI for an account on a system
See [RFC7565](datatracker.ietf.org/doc/html/rfc7565) for more information.
Constant Summary collapse
- COMPONENT =
The components of the URI
[:scheme, :account, :host].freeze
Instance Attribute Summary collapse
-
#account ⇒ String
The account part (also known as the userpart) of the URI.
Class Method Summary collapse
-
.build(args) ⇒ URI::Acct
Builds a Acct from components.
Instance Method Summary collapse
-
#initialize(*args) ⇒ URI::Acct
constructor
Instantiates a new Acct from a long list of components.
-
#to_s ⇒ String
Converts the URI into a string.
Constructor Details
#initialize(*args) ⇒ URI::Acct
Instantiates a new URI::Acct from a long list of components
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/bridgetown/webfinger/uri/acct.rb', line 72 def initialize(*args) super raise InvalidComponentError, "missing opaque part for acct URI" unless @opaque account, _, host = @opaque.rpartition("@") @opaque = nil if args[10] # arg_check self.account = account self.host = host else @account = account @host = host end end |
Instance Attribute Details
#account ⇒ String
The account part (also known as the userpart) of the URI
99 100 101 |
# File 'lib/bridgetown/webfinger/uri/acct.rb', line 99 def account @account end |
Class Method Details
.build(args) ⇒ URI::Acct
Builds a URI::Acct from components
Note: Do not enter already percent-encoded data as a component for the account because the implementation will do this step for you. If you’re building from components received externally, consider using ‘URI.decode_uri_component` before using it to build a URI with this method.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/bridgetown/webfinger/uri/acct.rb', line 50 def self.build(args) components = Util.make_components_hash(self, args) components[:account] ||= "" components[:account] &&= URI.encode_uri_component(components[:account]) components[:host] ||= "" components[:opaque] = "#{components.delete(:account)}@#{components.delete(:host)}" super(components) end |
Instance Method Details
#to_s ⇒ String
Converts the URI into a string
132 133 134 |
# File 'lib/bridgetown/webfinger/uri/acct.rb', line 132 def to_s @scheme + ":" + URI.encode_uri_component(account) + "@" + host end |