Class: Howcast::Client::Category

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from WatchAttrAccessors

attr_accessor, attr_accessors

Methods included from XmlMethods

#to_doc, #to_xml

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"


44
45
46
47
48
# File 'lib/howcast/client/category.rb', line 44

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.



29
30
31
# File 'lib/howcast/client/category.rb', line 29

def id
  @id
end

#nameObject

Returns the value of attribute name.



29
30
31
# File 'lib/howcast/client/category.rb', line 29

def name
  @name
end

#parent_idObject

Returns the value of attribute parent_id.



29
30
31
# File 'lib/howcast/client/category.rb', line 29

def parent_id
  @parent_id
end

#parentsObject

Returns the value of attribute parents.



29
30
31
# File 'lib/howcast/client/category.rb', line 29

def parents
  @parents
end

Returns the value of attribute permalink.



29
30
31
# File 'lib/howcast/client/category.rb', line 29

def permalink
  @permalink
end