Class: Entry
- Inherits:
-
Object
- Object
- Entry
- Defined in:
- lib/r43/entry.rb
Overview
Implements an entry object from 43 things. Currently only meant to be constructed by an R43::Request object.
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#content ⇒ Object
Returns the value of attribute content.
-
#dc_subject ⇒ Object
Returns the value of attribute dc_subject.
-
#entry_id ⇒ Object
Returns the value of attribute entry_id.
-
#goal ⇒ Object
Returns the value of attribute goal.
-
#id ⇒ Object
Returns the value of attribute id.
-
#issued ⇒ Object
Returns the value of attribute issued.
-
#link ⇒ Object
Returns the value of attribute link.
-
#num_comments ⇒ Object
Returns the value of attribute num_comments.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
-
.from_xml(xml) ⇒ Object
Builds an Entry object from an xml object.
Instance Method Summary collapse
-
#initialize ⇒ Entry
constructor
A new instance of Entry.
- #initialize_copy(entry) ⇒ Object
- #to_i ⇒ Object
Constructor Details
#initialize ⇒ Entry
Returns a new instance of Entry.
14 15 16 17 |
# File 'lib/r43/entry.rb', line 14 def initialize() # just to initialize the object, we'll always feed the attributes # in some other way end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def @author end |
#content ⇒ Object
Returns the value of attribute content.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def content @content end |
#dc_subject ⇒ Object
Returns the value of attribute dc_subject.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def dc_subject @dc_subject end |
#entry_id ⇒ Object
Returns the value of attribute entry_id.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def entry_id @entry_id end |
#goal ⇒ Object
Returns the value of attribute goal.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def goal @goal end |
#id ⇒ Object
Returns the value of attribute id.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def id @id end |
#issued ⇒ Object
Returns the value of attribute issued.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def issued @issued end |
#link ⇒ Object
Returns the value of attribute link.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def link @link end |
#num_comments ⇒ Object
Returns the value of attribute num_comments.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def num_comments @num_comments end |
#title ⇒ Object
Returns the value of attribute title.
11 12 13 |
# File 'lib/r43/entry.rb', line 11 def title @title end |
Class Method Details
.from_xml(xml) ⇒ Object
Builds an Entry object from an xml object. Normally, this is called by the get_entry method of an R43::Request object.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/r43/entry.rb', line 34 def Entry.from_xml(xml) entry = Entry.new if xml.elements["title"] then entry.title= xml.elements["title"].text end entry.dc_subject= xml.elements["dc:subject"].text entry.content= xml.elements["content"].text entry.num_comments= xml.elements["num_comments"].text.to_i entry.issued= xml.elements["issued"].text entry.link= xml.elements["link"].attributes["href"] entry.id= Id.from_xml(xml.elements["id"]) entry.entry_id = entry.id.to_i xml.elements.each("author") do |entry_element| entry.= Person.from_xml(entry_element) end goal = Goal.new xml.elements.each("goal") do |goal_entry| goal = Goal.from_xml(goal_entry) end entry.goal= goal entry end |
Instance Method Details
#initialize_copy(entry) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/r43/entry.rb', line 19 def initialize_copy(entry) @author = entry..clone if entry. @goal = entry.goal.clone if entry.goal @id = entry.id.clone if entry.id self end |
#to_i ⇒ Object
26 27 28 |
# File 'lib/r43/entry.rb', line 26 def to_i() @entry_id end |