Class: BungieClient::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/bungie_client/service.rb

Overview

Simple class for service structure

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Service

Initialize service by name with snake case style

Examples:

service =

Parameters:



21
22
23
24
25
26
27
28
29
# File 'lib/bungie_client/service.rb', line 21

def initialize(name)
  service = self.class.services[name]

  raise 'Undefined service' if service.nil?

  @type     = service[:method]
  @name     = service[:name]
  @endpoint = service[:endpoint]
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



3
4
5
# File 'lib/bungie_client/service.rb', line 3

def endpoint
  @endpoint
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/bungie_client/service.rb', line 3

def name
  @name
end

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/bungie_client/service.rb', line 3

def type
  @type
end

Class Method Details

.servicesHash

Get list of services



10
11
12
13
14
# File 'lib/bungie_client/service.rb', line 10

def self.services
  return @services unless @services.nil?

  @services = YAML.load_file "#{File.dirname(__FILE__)}/services.yml" || {}
end