Class: FacebookScrapper::Post

Inherits:
Object
  • Object
show all
Defined in:
lib/facebook_scrapper/post.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePost

Returns a new instance of Post.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/facebook_scrapper/post.rb', line 5

def initialize
  self.owner = ""
  self.text = ""
  self.like_count = 0
  self.comment_count = 0
  self.time = ""
  self.post_owner_link = ""
  self.comment_link = ""
  self.like_link = ""
  self.more_link = ""
  self.post_link = ""
end

Instance Attribute Details

#comment_countObject

Returns the value of attribute comment_count.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def comment_count
  @comment_count
end

Returns the value of attribute comment_link.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def comment_link
  @comment_link
end

#like_countObject

Returns the value of attribute like_count.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def like_count
  @like_count
end

Returns the value of attribute like_link.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def like_link
  @like_link
end

Returns the value of attribute more_link.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def more_link
  @more_link
end

#ownerObject

Returns the value of attribute owner.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def owner
  @owner
end

#post_linkObject

Returns the value of attribute post_link.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def post_link
  @post_link
end

#post_owner_linkObject

Returns the value of attribute post_owner_link.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def post_owner_link
  @post_owner_link
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def text
  @text
end

#timeObject

Returns the value of attribute time.



3
4
5
# File 'lib/facebook_scrapper/post.rb', line 3

def time
  @time
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
24
# File 'lib/facebook_scrapper/post.rb', line 18

def to_h
  hash = {}
  instance_variables.each do |var|
    hash[var.to_s.delete("@")] = instance_variable_get(var)
  end
  return hash
end

#to_jsonObject



26
27
28
# File 'lib/facebook_scrapper/post.rb', line 26

def to_json
  to_h.to_json
end

#to_strObject



30
31
32
33
34
35
36
37
38
39
# File 'lib/facebook_scrapper/post.rb', line 30

def to_str
  s = "\nPost by #{self.owner}: "
  s += "#{self.text} \n"
  s += "Likes: #{self.like_count.to_s} - "
  s += "Comments: #{self.comment_count.to_s} - "
  s += "#{self.time} "
  s += " - Privacy: #{self.privacy}\n-"
  s += "\n Comment -> #{self.comment_link}\n"
  return s
end