Class: Flickry::Comment

Inherits:
Base show all
Defined in:
lib/flickry/comment.rb

Instance Method Summary collapse

Methods inherited from Base

#attributes

Methods inherited from SuperStruct

#[], #[]=, #each, #each_pair, #members

Constructor Details

#initialize(comment) ⇒ Comment

Returns a new instance of Comment.



3
4
5
6
7
8
# File 'lib/flickry/comment.rb', line 3

def initialize(comment)
  super(nil)
  extract_attrs!(comment, [:fid, :authorname, :datecreate, :permalink])
  self.content = comment.to_s
  self.author_id = comment.author
end

Instance Method Details

#authorObject

Get a Person record for the author_id



29
30
31
# File 'lib/flickry/comment.rb', line 29

def author
  Flickry::Person.find(self.author_id)
end

#comment_idObject



10
11
12
# File 'lib/flickry/comment.rb', line 10

def comment_id
  self.fid
end

#created_atObject

datecreate converted into Time object



24
25
26
# File 'lib/flickry/comment.rb', line 24

def created_at
  Time.at(self.datecreate.to_i)
end

#nameObject

name = authornane



34
35
36
# File 'lib/flickry/comment.rb', line 34

def name
  self.authorname
end

#to_sObject



14
15
16
# File 'lib/flickry/comment.rb', line 14

def to_s
  self.content
end

#to_urlObject

Clean permalink



19
20
21
# File 'lib/flickry/comment.rb', line 19

def to_url
  clean(self.permalink)
end