Class: Entry

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeEntry

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

#authorObject

Returns the value of attribute author.



11
12
13
# File 'lib/r43/entry.rb', line 11

def author
  @author
end

#contentObject

Returns the value of attribute content.



11
12
13
# File 'lib/r43/entry.rb', line 11

def content
  @content
end

#dc_subjectObject

Returns the value of attribute dc_subject.



11
12
13
# File 'lib/r43/entry.rb', line 11

def dc_subject
  @dc_subject
end

#entry_idObject

Returns the value of attribute entry_id.



11
12
13
# File 'lib/r43/entry.rb', line 11

def entry_id
  @entry_id
end

#goalObject

Returns the value of attribute goal.



11
12
13
# File 'lib/r43/entry.rb', line 11

def goal
  @goal
end

#idObject

Returns the value of attribute id.



11
12
13
# File 'lib/r43/entry.rb', line 11

def id
  @id
end

#issuedObject

Returns the value of attribute issued.



11
12
13
# File 'lib/r43/entry.rb', line 11

def issued
  @issued
end

Returns the value of attribute link.



11
12
13
# File 'lib/r43/entry.rb', line 11

def link
  @link
end

#num_commentsObject

Returns the value of attribute num_comments.



11
12
13
# File 'lib/r43/entry.rb', line 11

def num_comments
  @num_comments
end

#titleObject

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.author= 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.author.clone if entry.author
  @goal = entry.goal.clone if entry.goal
  @id = entry.id.clone if entry.id
  self
end

#to_iObject



26
27
28
# File 'lib/r43/entry.rb', line 26

def to_i()
  @entry_id
end