Class: Howcast::Client::Category

Inherits:
Object
  • Object
show all
Extended by:
WatchAttrAccessors
Defined in:
lib/howcast/client/category.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WatchAttrAccessors

attr_accessor, attr_accessors

Constructor Details

#initialize(attributes = {}) ⇒ Category

Creates a new Category object which is used to encapsulate all the attributes available from the Howcast Category API. The parents attribute will be an array of category ancestors of the form:

[{:id => 1, :name => 'root'}, {:id => 2, :name => 'immediate parent'}]

Inputs

  • attributes – A hash to set the various attributes of the category object

Examples

Initialize a category with name “Arts & Crafts”

Category.new :name => "Arts & Crafts"


42
43
44
45
46
# File 'lib/howcast/client/category.rb', line 42

def initialize(attributes={})
  attributes.each do |k, v|
    self.send("#{k}=", v) if self.respond_to?(k)
  end
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



27
28
29
# File 'lib/howcast/client/category.rb', line 27

def id
  @id
end

#nameObject

Returns the value of attribute name.



27
28
29
# File 'lib/howcast/client/category.rb', line 27

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



27
28
29
# File 'lib/howcast/client/category.rb', line 27

def parent_id
  @parent_id
end

#parentsObject

Returns the value of attribute parents.



27
28
29
# File 'lib/howcast/client/category.rb', line 27

def parents
  @parents
end