Class: RestBooks::Models::Category
- Inherits:
-
Object
- Object
- RestBooks::Models::Category
- Includes:
- RestBooks::Model
- Defined in:
- lib/restbooks/models/category.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Instance Method Summary collapse
-
#initialize(element) ⇒ Category
constructor
A new instance of Category.
- #to_hash ⇒ Object
Methods included from RestBooks::Model
Constructor Details
#initialize(element) ⇒ Category
Returns a new instance of Category.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/restbooks/models/category.rb', line 30 def initialize( element ) if element @element = element @element.elements.each do |tag| case tag.name when 'title' @title = tag.text.strip() @id = CGI.escape( @title ) when 'updated' @updated = Date.parse( tag.text ) end end else @element = REXML::Element.new( 'entry' ) end end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
28 29 30 |
# File 'lib/restbooks/models/category.rb', line 28 def description @description end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
28 29 30 |
# File 'lib/restbooks/models/category.rb', line 28 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
28 29 30 |
# File 'lib/restbooks/models/category.rb', line 28 def title @title end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
28 29 30 |
# File 'lib/restbooks/models/category.rb', line 28 def updated @updated end |
Instance Method Details
#to_hash ⇒ Object
47 48 49 50 51 |
# File 'lib/restbooks/models/category.rb', line 47 def to_hash return { :title => @title, :id => @id, :updated => @updated } end |