Module: Ravelry::Needles

Extended by:
Needles
Included in:
Needles
Defined in:
lib/ravelry/needles.rb

Overview

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

Instance Method Summary collapse

Instance Method Details

#list(username) ⇒ Object

Get needle records for an individual user.

Arguments: username (string, required)



31
32
33
34
# File 'lib/ravelry/needles.rb', line 31

def list(username)
  result = Utils::Request.get("people/#{username}/needles/list.json", :needle_records)
  result.map { |needle| Needle.new(needle) }
end

#sizes(craft = '') ⇒ Object

Get available sizes for each needle type. If you don’t pass an argument, you’ll get all knitting needle and crochet hook sizes.

If you pass an argument (‘’knitting’‘ or `’crochet’‘), you will only get results that match that type.

Arguments: needle type (string, optional)



14
15
16
17
18
# File 'lib/ravelry/needles.rb', line 14

def sizes(craft='')
  result = Utils::Request
    .get('needles/sizes.json', :needle_sizes, {:craft => craft})
  result.map { |needle| Needle.new(needle) }
end

#typesObject

Get needle types.



22
23
24
25
# File 'lib/ravelry/needles.rb', line 22

def types
  result = Utils::Request.get("needles/types.json", :needle_types)
  result.map { |needle| Needle.new(needle) }
end