Class: FBScrape::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/fb_scrape/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(payload, conversation_id, page_id = nil) ⇒ Message

Returns a new instance of Message.



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

def initialize(payload, conversation_id, page_id=nil)
  @page_id = page_id
  @conversation_id = conversation_id

  @id = payload['id']
  @text = payload['message']
  @created_at = DateTime.strptime payload['created_time'] if payload['created_time']

  @from_id = payload['from']['id']
  @from_name = payload['from']['name']
  @to_id = payload['to']['data'].first['id']
  @to_name = payload['to']['data'].first['name']
end

Instance Attribute Details

#conversation_idObject

Returns the value of attribute conversation_id.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def conversation_id
  @conversation_id
end

#created_atObject

Returns the value of attribute created_at.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def created_at
  @created_at
end

#from_idObject

Returns the value of attribute from_id.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def from_id
  @from_id
end

#from_nameObject

Returns the value of attribute from_name.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def from_name
  @from_name
end

#idObject

Returns the value of attribute id.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def id
  @id
end

#reply_idObject

Returns the value of attribute reply_id.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def reply_id
  @reply_id
end

#textObject

Returns the value of attribute text.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def text
  @text
end

#to_idObject

Returns the value of attribute to_id.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def to_id
  @to_id
end

#to_nameObject

Returns the value of attribute to_name.



2
3
4
# File 'lib/fb_scrape/message.rb', line 2

def to_name
  @to_name
end

Instance Method Details

#is_incoming?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/fb_scrape/message.rb', line 19

def is_incoming?
  @to_id == @page_id
end

#is_reply?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/fb_scrape/message.rb', line 23

def is_reply?
  !is_incoming?
end