Module: Ravelry::Misc

Extended by:
Misc
Included in:
Misc
Defined in:
lib/ravelry/misc.rb

Overview

Handles API request for the ‘Misc` endpoints. Always returns an array of objects.

Instance Method Summary collapse

Instance Method Details

#color_familiesObject

Handles GET API call and parses JSON response for the ‘Misc#color_families` Ravelry endpoint.

Returns an array of ColorFamily objects.



12
13
14
15
# File 'lib/ravelry/misc.rb', line 12

def color_families
  result = Utils::Request.get("color_families.json", :color_families)
  result.map { |color_family| ColorFamily.new(color_family) }
end

#current_userObject

Make a GET API call for the current authenticated user. Without the OAuth setup, this will just be you, the requester.

Returns a User object.

Note: the returned ‘User` won’t have everything from a standard User request, but you will have the information necessary to make a request for the full profile if desired.



32
33
34
35
36
37
# File 'lib/ravelry/misc.rb', line 32

def current_user
  result = Utils::Request.get("current_user.json", :user)
  user = Ravelry::User.new
  user.data = result
  return user
end

#yarn_weightsObject

Handles GET API call and parses JSON response for the ‘Misc#color_families` Ravelry endpoint.

Returns an array of ColorFamily objects.



21
22
23
24
# File 'lib/ravelry/misc.rb', line 21

def yarn_weights
  result = Utils::Request.get("yarn_weights.json", :yarn_weights)
  result.map { |yarn_weight| YarnWeight.new(yarn_weight) }
end