class Ravelry::Category
There is no API access point for PatternCategories. The information used to create `Ravelry::Category` comes from {Ravelry::Pattern} objects.
You should not create `Category` objects manually; they are all created–and owned by–by a {Ravelry::Pattern}.
See {Ravelry::Pattern} for more information about `Pattern` objects.
This does not inherit from {Ravelry::Data} because it doesn't have a corresponding API endpoint.
Attributes
Public Class Methods
Creates new `Category` from Ravelry
API PatternCategories attributes up to the great grandparent level
All class variables are readonly.
# File lib/ravelry/category.rb, line 18 def initialize(category) @name = category[:name] @permalink = category[:permalink] @category = category set_relatives end
Protected Instance Methods
Returns parent name and sets grandparent attributes from existing `data`.
# File lib/ravelry/category.rb, line 35 def grandparent if @category[:parent][:parent] @grandparent_permalink = @category[:parent][:parent][:permalink] @grandparent_name = @category[:parent][:parent][:name] end end
Returns parent name and sets greatgrandparent attributes from existing `data`.
# File lib/ravelry/category.rb, line 43 def greatgrandparent if @category[:parent][:parent][:parent] @greatgrandparent_permalink = @category[:parent][:parent][:parent][:permalink] @greatgrandparent_name = @category[:parent][:parent][:parent][:name] end end
Returns parent name and sets parent attributes from existing `data`.
# File lib/ravelry/category.rb, line 27 def parent if @category[:parent] @parent_permalink = @category[:parent][:permalink] @parent_name = @category[:parent][:name] end end
Private Instance Methods
# File lib/ravelry/category.rb, line 51 def set_relatives parent if @category[:parent] grandparent if @category[:parent][:parent] greatgrandparent if @category[:parent][:parent][:parent] end