class LiveJournal::Friend

Represents a LiveJournal friend relationship. See LiveJournal::Request::Friends to get an array of these.

Attributes

background[RW]

as HTML color, like '#ff0000'

foreground[RW]

as HTML color, like '#ff0000'

fullname[RW]
groupmask[RW]

bitfield of friend groups this friend is a member of

type[RW]

friend type. possible values: :community, :news, :syndicated, :shared, :identity, :user

username[RW]

Public Class Methods

new() click to toggle source
# File lib/livejournal/friends.rb, line 38
def initialize
  @username = nil
  @fullname = nil
  @background = nil
  @foreground = nil
  @groupmask = nil
  @type = nil
end

Public Instance Methods

from_request(req) click to toggle source
# 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() click to toggle source
# File lib/livejournal/friends.rb, line 65
def to_s
  "#{@username}: #{@fullname}"
end