Class: StubRequests::URI::Builder
- Defined in:
- lib/stub_requests/uri/builder.rb
Overview
Builder constructs and validates URIs
:reek:TooManyInstanceVariables { max_instance_variables: 6 }
Constant Summary collapse
- URL_SEGMENT_REGEX =
Returns A pattern for matching url segment keys
/(:\w+)/.freeze
Instance Attribute Summary collapse
- #host ⇒ Object readonly
- #path ⇒ Object readonly
- #replacements ⇒ Object readonly
- #template ⇒ Object readonly
- #unreplaced ⇒ Object readonly
- #unused ⇒ Object readonly
Class Method Summary collapse
-
.build(host, template, replacements = {}) ⇒ String
Convenience method to avoid .new.build.
Instance Method Summary collapse
-
#build ⇒ String
Builds a URI string.
-
#initialize(host, template, replacements = {}) ⇒ Builder
constructor
Initializes a new Builder.
Constructor Details
#initialize(host, template, replacements = {}) ⇒ Builder
Initializes a new Builder
73 74 75 76 77 78 |
# File 'lib/stub_requests/uri/builder.rb', line 73 def initialize(host, template, replacements = {}) @host = +host @template = +template @path = +@template.dup @replacements = replacements end |
Instance Attribute Details
#host ⇒ Object (readonly)
43 44 45 |
# File 'lib/stub_requests/uri/builder.rb', line 43 def host @host end |
#path ⇒ Object (readonly)
51 52 53 |
# File 'lib/stub_requests/uri/builder.rb', line 51 def path @path end |
#replacements ⇒ Object (readonly)
55 56 57 |
# File 'lib/stub_requests/uri/builder.rb', line 55 def replacements @replacements end |
#template ⇒ Object (readonly)
47 48 49 |
# File 'lib/stub_requests/uri/builder.rb', line 47 def template @template end |
#unreplaced ⇒ Object (readonly)
63 64 65 |
# File 'lib/stub_requests/uri/builder.rb', line 63 def unreplaced @unreplaced end |
#unused ⇒ Object (readonly)
59 60 61 |
# File 'lib/stub_requests/uri/builder.rb', line 59 def unused @unused end |
Class Method Details
.build(host, template, replacements = {}) ⇒ String
Convenience method to avoid .new.build
36 37 38 |
# File 'lib/stub_requests/uri/builder.rb', line 36 def self.build(host, template, replacements = {}) new(host, template, replacements).build end |
Instance Method Details
#build ⇒ String
Builds a URI string
89 90 91 92 93 94 |
# File 'lib/stub_requests/uri/builder.rb', line 89 def build build_uri run_validations uri end |