Class: PostHaste::Comment

Inherits:
Object
  • Object
show all
Defined in:
lib/post_haste/comment.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Comment

Returns a new instance of Comment.



7
8
9
10
11
# File 'lib/post_haste/comment.rb', line 7

def initialize(params={})
  params.each_pair do |k,v|
   instance_variable_set("@#{k}", v)
  end
end

Instance Attribute Details

#article_urlObject (readonly)

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def article_url
  @article_url
end

#authorObject (readonly)

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def author
  @author
end

#contentObject (readonly)

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def content
  @content
end

#idObject (readonly)

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def id
  @id
end

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def permalink
  @permalink
end

#publishedObject (readonly)

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def published
  @published
end

#statusObject (readonly)

Represents a comment on a Washington Post story



5
6
7
# File 'lib/post_haste/comment.rb', line 5

def status
  @status
end

Class Method Details

.create_comments_from_objects(article_url, comments) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/post_haste/comment.rb', line 13

def self.create_comments_from_objects(article_url, comments)
  results = []
  comments.each do |comment|
    c = Comment.new({:id => comment['object']['id'], :article_url => article_url, :author => comment['actor']['title'], :content => comment['object']['content'], :status => comment['object']['status'], :published => DateTime.parse(comment['object']['published'])})
    results << c
  end
  results
end