Class: Mumukit::Bridge::Bibliotheca
- Inherits:
-
Object
- Object
- Mumukit::Bridge::Bibliotheca
- Defined in:
- lib/mumukit/bridge/bibliotheca.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #book(slug) ⇒ Object
- #books ⇒ Object
- #get(path) ⇒ Object
- #get_collection(name) ⇒ Object
- #get_element(name, slug) ⇒ Object
- #guide(slug) ⇒ Object
- #guides ⇒ Object
-
#initialize(url) ⇒ Bibliotheca
constructor
A new instance of Bibliotheca.
- #topic(slug) ⇒ Object
- #topics ⇒ Object
Constructor Details
#initialize(url) ⇒ Bibliotheca
Returns a new instance of Bibliotheca.
6 7 8 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 6 def initialize(url) @url = url end |
Instance Attribute Details
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 4 def url @url end |
Instance Method Details
#book(slug) ⇒ Object
30 31 32 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 30 def book(slug) get_element 'books', slug end |
#books ⇒ Object
18 19 20 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 18 def books get_collection 'books' end |
#get(path) ⇒ Object
42 43 44 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 42 def get(path) JSON.parse RestClient.get("#{url}/#{path}") end |
#get_collection(name) ⇒ Object
34 35 36 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 34 def get_collection(name) get(name)[name] end |
#get_element(name, slug) ⇒ Object
38 39 40 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 38 def get_element(name, slug) get "#{name}/#{slug}" end |
#guide(slug) ⇒ Object
22 23 24 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 22 def guide(slug) get_element 'guides', slug end |
#guides ⇒ Object
10 11 12 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 10 def guides get_collection 'guides' end |
#topic(slug) ⇒ Object
26 27 28 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 26 def topic(slug) get_element 'topics', slug end |
#topics ⇒ Object
14 15 16 |
# File 'lib/mumukit/bridge/bibliotheca.rb', line 14 def topics get_collection 'topics' end |