Class: Veye::API::Resource

Inherits:
BaseResource show all
Defined in:
lib/veye/api/resource.rb

Instance Attribute Summary

Attributes inherited from BaseResource

#full_path, #resource

Instance Method Summary collapse

Methods inherited from BaseResource

build_url

Constructor Details

#initialize(path = nil) ⇒ Resource

Returns a new instance of Resource.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/veye/api/resource.rb', line 7

def initialize(path = nil)
  super(path)
  #hardcoded values come from api.rb file
  timeout_val = safe_to_i( $global_options[:timeout] )
  timeout = ( timeout_val > 0 ) ? timeout_val : 90 # dont allow 0
  open_timeout_val = safe_to_i( $global_options[:open_timeout] )
  open_timeout = ( open_timeout_val > 0 ) ? open_timeout_val : 10 #dont allow 0

  @resource = RestClient::Resource.new(
    @full_path,
    timeout: timeout,
    open_timeout: open_timeout,
  )
end

Instance Method Details

#safe_to_i(val) ⇒ Object



22
23
24
25
26
# File 'lib/veye/api/resource.rb', line 22

def safe_to_i(val)
  val.to_i
rescue
  return 0
end