Class: FbGraph::Tag

Inherits:
Object
  • Object
show all
Includes:
Comparison, Serialization
Defined in:
lib/fb_graph/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Serialization

#as_json, #to_json

Methods included from Comparison

#==

Constructor Details

#initialize(attributes = {}) ⇒ Tag

Returns a new instance of Tag.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fb_graph/tag.rb', line 8

def initialize(attributes = {})
  @x = attributes[:x]
  @y = attributes[:y]
  if attributes[:created_time]
    @created_time = Time.parse(attributes[:created_time]).utc
  end
  if attributes[:id].present?
    @user = User.new(attributes[:id], attributes)
  end
  @name = attributes[:name]
end

Instance Attribute Details

#created_timeObject

Returns the value of attribute created_time.



6
7
8
# File 'lib/fb_graph/tag.rb', line 6

def created_time
  @created_time
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/fb_graph/tag.rb', line 6

def name
  @name
end

#userObject

Returns the value of attribute user.



6
7
8
# File 'lib/fb_graph/tag.rb', line 6

def user
  @user
end

#xObject

Returns the value of attribute x.



6
7
8
# File 'lib/fb_graph/tag.rb', line 6

def x
  @x
end

#yObject

Returns the value of attribute y.



6
7
8
# File 'lib/fb_graph/tag.rb', line 6

def y
  @y
end

Instance Method Details

#to_hash(options = {}) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/fb_graph/tag.rb', line 20

def to_hash(options = {})
  hash = {
    :tag_text => self.name,
    :x => self.x,
    :y => self.y
  }
  hash[:tag_uid] = self.user.identifier if self.user
  hash
end