class Vermillion::Helper::Endpoint

Attributes

server[W]

Set the @server variable externally

Public Class Methods

new(initial_path) click to toggle source

Creates the Endpoint object with default values for internal variables Params:

initial_path

Starting point of the URL this class will build

# File lib/client/helper/endpoint.rb, line 10
def initialize(initial_path)
  @path = { default: initial_path }
  @server = nil
  @protocol = "http://"
end

Public Instance Methods

add(key, value) click to toggle source

Add a section to the path Params:

key

Symbol, the key to identify the section

value

Any value to store with the associated key

# File lib/client/helper/endpoint.rb, line 27
def add(key, value)
  @path[key.to_sym] = value
end
delete(key) click to toggle source

Deletes a value from the internal hash based on a key Params:

key

Symbol, the key to identify the section

# File lib/client/helper/endpoint.rb, line 41
def delete(key)
  @path.delete(key)
end
exists?(key) click to toggle source

Checks whether a key exists Params:

key

Symbol, the key to identify the section

# File lib/client/helper/endpoint.rb, line 48
def exists?(key)
  @path.key? key
end
get(key) click to toggle source

Return a value based on the provided key Params:

key

Symbol, the key to identify the section

# File lib/client/helper/endpoint.rb, line 34
def get(key)
  @path[key.to_sym]
end
protocol=(use_https) click to toggle source

Set endpoint protocol Params:

use_https

Boolean value for whether to use HTTPS

# File lib/client/helper/endpoint.rb, line 19
def protocol=(use_https)
  @protocol = 'https://' if use_https
end
to_s() click to toggle source

Override the #to_s method to return an endpoint fragment

# File lib/client/helper/endpoint.rb, line 53
def to_s
  output = @protocol + @server
  @path.each_pair do |_k, value|
    output += value
  end
  output
end