Class: BusinessCentral::URLBuilder
- Inherits:
-
Object
- Object
- BusinessCentral::URLBuilder
- Defined in:
- lib/business_central/url_builder.rb
Instance Attribute Summary collapse
-
#child_id ⇒ Object
readonly
Returns the value of attribute child_id.
-
#child_path ⇒ Object
readonly
Returns the value of attribute child_path.
-
#parent_id ⇒ Object
readonly
Returns the value of attribute parent_id.
-
#parent_path ⇒ Object
readonly
Returns the value of attribute parent_path.
-
#sequence ⇒ Object
readonly
Returns the value of attribute sequence.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#build ⇒ Object
Creates the URL string from the provided options.
-
#initialize(parent_path, parent_id, options = {}) ⇒ URLBuilder
constructor
A new instance of URLBuilder.
Constructor Details
#initialize(parent_path, parent_id, options = {}) ⇒ URLBuilder
Returns a new instance of URLBuilder.
15 16 17 18 19 20 21 22 23 |
# File 'lib/business_central/url_builder.rb', line 15 def initialize(parent_path, parent_id, = {}) @url = "" @parent_path = parent_path @parent_id = parent_id @child_path = .fetch(:child_path, nil) @child_id = .fetch(:child_id, nil) @sequence = .fetch(:sequence, nil) build end |
Instance Attribute Details
#child_id ⇒ Object (readonly)
Returns the value of attribute child_id.
9 10 11 |
# File 'lib/business_central/url_builder.rb', line 9 def child_id @child_id end |
#child_path ⇒ Object (readonly)
Returns the value of attribute child_path.
9 10 11 |
# File 'lib/business_central/url_builder.rb', line 9 def child_path @child_path end |
#parent_id ⇒ Object (readonly)
Returns the value of attribute parent_id.
8 9 10 |
# File 'lib/business_central/url_builder.rb', line 8 def parent_id @parent_id end |
#parent_path ⇒ Object (readonly)
Returns the value of attribute parent_path.
8 9 10 |
# File 'lib/business_central/url_builder.rb', line 8 def parent_path @parent_path end |
#sequence ⇒ Object (readonly)
Returns the value of attribute sequence.
9 10 11 |
# File 'lib/business_central/url_builder.rb', line 9 def sequence @sequence end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/business_central/url_builder.rb', line 7 def url @url end |
Instance Method Details
#build ⇒ Object
Creates the URL string from the provided options
27 28 29 30 31 |
# File 'lib/business_central/url_builder.rb', line 27 def build @url = "/#{@parent_path}(#{@parent_id})" @url += "/#{@child_path}" unless @child_path.nil? @url += "(#{@child_id})" unless @child_id.nil? end |