Decathlon / sports-api-wrapper

Sports API wrapper
MIT License
3 stars 2 forks source link

Getting uninitialized constant Decathlon (NameError) #1

Closed alextoul closed 5 years ago

alextoul commented 5 years ago
# GOAL: Suggest the user a sport to practice knowing he loves snowboarding
#

gem 'decathlon-sports'

# Get the list of Decathlon Sports
sports = Decathlon::Sports.all
# => uninitialized constant Decathlon (NameError)

# Find snowboard
snowboard = Decathlon::Sports.find(73)

# Find suggested sport 
suggested_sports = Decathlon::Sports::Recommendations.get(snowboard.id)

printf "We suggest you practice %d because you love snowboarding\n", suggested_sports

https://gist.github.com/alextoul/f4417bab1a33d09971b321938ba6af67

CaioBianchi commented 5 years ago

If you're using the gem on a standalone ruby file, you'll need to require the library, as such:

require 'decathlon/sports'

sports = Decathlon::Sports.all
puts sports

I included the decathlon namespace because the goal here is to eventually have multiple wrappers under that namespace for our different APIs.

Let me know if that's clear. But I'll add a note in the Readme file nonetheless. 👍