class StackerBee::API

Attributes

api_path[RW]

Public Class Methods

new(attrs = {}) click to toggle source
# File lib/stacker_bee/api.rb, line 10
def initialize(attrs = {})
  attrs.each_pair do |key, value|
    send "#{key}=", value
  end
end

Public Instance Methods

[](key) click to toggle source
# File lib/stacker_bee/api.rb, line 16
def [](key)
  endpoints[uncase(key)]
end
key?(key) click to toggle source
# File lib/stacker_bee/api.rb, line 20
def key?(key)
  endpoints.key?(uncase(key))
end

Protected Instance Methods

apis_by_endpoint(response) click to toggle source
# File lib/stacker_bee/api.rb, line 37
def apis_by_endpoint(response)
  response['listapisresponse']['api'].each_with_object({}) do |api, memo|
    memo[uncase(api['name'])] = api
  end
end
endpoints() click to toggle source
# File lib/stacker_bee/api.rb, line 26
def endpoints
  @endpoints ||= read_endpoints
end
read_endpoints() click to toggle source
# File lib/stacker_bee/api.rb, line 30
def read_endpoints
  return unless api_path
  json     = File.read(api_path)
  response = MultiJson.load(json)
  apis_by_endpoint(response)
end