Class: Ace::Support::Nav::Models::ResourceUri
- Inherits:
-
Object
- Object
- Ace::Support::Nav::Models::ResourceUri
- Defined in:
- lib/ace/support/nav/models/resource_uri.rb
Overview
Represents a parsed resource URI
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #cascade_search? ⇒ Boolean
-
#initialize(raw_uri, config_loader: nil) ⇒ ResourceUri
constructor
A new instance of ResourceUri.
- #source_specific? ⇒ Boolean
- #to_h ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(raw_uri, config_loader: nil) ⇒ ResourceUri
Returns a new instance of ResourceUri.
13 14 15 16 17 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 13 def initialize(raw_uri, config_loader: nil) @raw = raw_uri @config_loader = config_loader || Molecules::ConfigLoader.new parse_uri(raw_uri) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 11 def path @path end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
11 12 13 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 11 def protocol @protocol end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
11 12 13 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 11 def raw @raw end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
11 12 13 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 11 def source @source end |
Instance Method Details
#cascade_search? ⇒ Boolean
27 28 29 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 27 def cascade_search? source.nil? end |
#source_specific? ⇒ Boolean
23 24 25 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 23 def source_specific? !source.nil? end |
#to_h ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 35 def to_h { raw: raw, protocol: protocol, source: source, path: path, source_specific: source_specific?, cascade_search: cascade_search? } end |
#to_s ⇒ Object
31 32 33 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 31 def to_s raw end |
#valid? ⇒ Boolean
19 20 21 |
# File 'lib/ace/support/nav/models/resource_uri.rb', line 19 def valid? !protocol.nil? && @config_loader.valid_protocol?(protocol) end |