Class: GaExampleGem::Client

Inherits:
Object
  • Object
show all
Includes:
Configuration, HTTParty
Defined in:
lib/ga_example_gem/client.rb

Overview

This is our client that we can initialize with GaExampleGem.new

Instance Attribute Summary

Attributes included from Configuration

#api_key, #oauth_key

Instance Method Summary collapse

Methods included from Configuration

#configure, #reset

Constructor Details

#initializeClient

This resets our API keys when it is initialized



14
15
16
# File 'lib/ga_example_gem/client.rb', line 14

def initialize
   reset
end

Instance Method Details

#get_xkcd(number) ⇒ Object

This method gets the JSON for a single XKCD comic by number



20
21
22
23
24
# File 'lib/ga_example_gem/client.rb', line 20

def get_xkcd(number)
	# This works too
	# JSON.parse self.class.get("http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}")
	JSON.parse HTTParty.get("http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}")
end