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
9
# File 'lib/flickry/comment.rb', line 3

def initialize(comment)
  super(nil)
  @comment_id = comment.id
  extract_attrs!(comment, [: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



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

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

#comment_idObject



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

def comment_id
  @comment_id
end

#created_atObject

datecreate converted into Time object



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

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

#nameObject

name = authornane



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

def name
  self.authorname
end

#to_sObject



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

def to_s
  self.content
end

#to_urlObject

Clean permalink



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

def to_url
  clean(self.permalink)
end