Class: Veye::API::BaseResource

Inherits:
Object
  • Object
show all
Defined in:
lib/veye/api/base_resource.rb

Overview

extends child classes with URL and API helpers

Direct Known Subclasses

Resource

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = nil) ⇒ BaseResource

Returns a new instance of BaseResource.



7
8
9
# File 'lib/veye/api/base_resource.rb', line 7

def initialize(path = nil)
  @full_path = "#{$global_options[:url]}#{path}"
end

Instance Attribute Details

#full_pathObject (readonly)

Returns the value of attribute full_path.



5
6
7
# File 'lib/veye/api/base_resource.rb', line 5

def full_path
  @full_path
end

#resourceObject (readonly)

Returns the value of attribute resource.



5
6
7
# File 'lib/veye/api/base_resource.rb', line 5

def resource
  @resource
end

Class Method Details

.build_url(global_options) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/veye/api/base_resource.rb', line 11

def self.build_url(global_options)
  resource_url = nil
  protocol = global_options[:protocol]
  server = global_options[:server]
  port = global_options.fetch(:port, '')
  path = global_options[:path]

  if port.to_s.empty?
    resource_url = "#{protocol}://#{server}/#{path}"
  else
    resource_url = "#{protocol}://#{server}:#{port}/#{path}"
  end

  resource_url
end