Class: BBC::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/bbc/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApi

Returns a new instance of Api.



11
12
13
# File 'lib/bbc/base.rb', line 11

def initialize
  @response = JSON.parse(URI::Uri.new(URI(BBC.api_url+"/topics")).response.body)["topics"]
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



9
10
11
# File 'lib/bbc/base.rb', line 9

def response
  @response
end

#topicsObject

Returns the value of attribute topics.



8
9
10
# File 'lib/bbc/base.rb', line 8

def topics
  @topics
end

Instance Method Details

#build_topics_hashObject



23
24
25
# File 'lib/bbc/base.rb', line 23

def build_topics_hash
  @topics.each_with_index.inject({}){|result, (element,i)| result.merge Hash[i.succ, element]}
end