Class: LiveJournal::Friend
- Inherits:
-
Object
- Object
- LiveJournal::Friend
- Defined in:
- lib/livejournal/friends.rb
Overview
Represents a LiveJournal friend relationship. See LiveJournal::Request::Friends to get an array of these.
Instance Attribute Summary collapse
-
#background ⇒ Object
as HTML color, like ‘#ff0000’.
-
#foreground ⇒ Object
as HTML color, like ‘#ff0000’.
-
#fullname ⇒ Object
Returns the value of attribute fullname.
-
#groupmask ⇒ Object
bitfield of friend groups this friend is a member of.
-
#type ⇒ Object
friend type.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #from_request(req) ⇒ Object
-
#initialize ⇒ Friend
constructor
A new instance of Friend.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Friend
Returns a new instance of Friend.
38 39 40 41 42 43 44 45 |
# File 'lib/livejournal/friends.rb', line 38 def initialize @username = nil @fullname = nil @background = nil @foreground = nil @groupmask = nil @type = nil end |
Instance Attribute Details
#background ⇒ Object
as HTML color, like ‘#ff0000’
33 34 35 |
# File 'lib/livejournal/friends.rb', line 33 def background @background end |
#foreground ⇒ Object
as HTML color, like ‘#ff0000’
33 34 35 |
# File 'lib/livejournal/friends.rb', line 33 def foreground @foreground end |
#fullname ⇒ Object
Returns the value of attribute fullname.
31 32 33 |
# File 'lib/livejournal/friends.rb', line 31 def fullname @fullname end |
#groupmask ⇒ Object
bitfield of friend groups this friend is a member of
35 36 37 |
# File 'lib/livejournal/friends.rb', line 35 def groupmask @groupmask end |
#type ⇒ Object
friend type. possible values: :community, :news, :syndicated, :shared, :identity, :user
37 38 39 |
# File 'lib/livejournal/friends.rb', line 37 def type @type end |
#username ⇒ Object
Returns the value of attribute username.
31 32 33 |
# File 'lib/livejournal/friends.rb', line 31 def username @username end |
Instance Method Details
#from_request(req) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/livejournal/friends.rb', line 46 def from_request(req) @username = req['user'] @fullname = req['name'] @foreground = req['fg'] @background = req['bg'] @groupmask = req['groupmask'] @type = case req['type'] when 'community'; :community when 'news'; :news when 'syndicated'; :syndicated when 'shared'; :shared when 'identity'; :identity when nil; :user else raise LiveJournal::Request::ProtocolException.new( "unknown friend type: #{req['type']}") end self end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/livejournal/friends.rb', line 65 def to_s "#{@username}: #{@fullname}" end |