Class: LiveJournal::User
- Inherits:
-
Object
- Object
- LiveJournal::User
- Defined in:
- lib/livejournal/basic.rb
Overview
A LiveJournal user. Given a username, password, and server, running a LiveJournal::Request::Login will fill in the other fields.
Instance Attribute Summary collapse
-
#fullname ⇒ Object
User’s self-reported name, as retrieved by LiveJournal::Request::Login.
-
#journals ⇒ Object
Journals the user has posting access to.
-
#password ⇒ Object
parameter when creating a User.
-
#server ⇒ Object
parameter when creating a User.
-
#usejournal ⇒ Object
Set usejournal to log in as user username but act as user usejournal.
-
#username ⇒ Object
parameter when creating a User.
Instance Method Summary collapse
- #canonical_journal_name ⇒ Object
-
#initialize(username = nil, password = nil, server = nil) ⇒ User
constructor
A new instance of User.
- #journal ⇒ Object
- #journal_url ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(username = nil, password = nil, server = nil) ⇒ User
Returns a new instance of User.
71 72 73 74 75 76 |
# File 'lib/livejournal/basic.rb', line 71 def initialize(username=nil, password=nil, server=nil) @username = username @password = password @usejournal = nil @server = server || LiveJournal::DEFAULT_SERVER end |
Instance Attribute Details
#fullname ⇒ Object
User’s self-reported name, as retrieved by LiveJournal::Request::Login
67 68 69 |
# File 'lib/livejournal/basic.rb', line 67 def fullname @fullname end |
#journals ⇒ Object
Journals the user has posting access to
69 70 71 |
# File 'lib/livejournal/basic.rb', line 69 def journals @journals end |
#password ⇒ Object
parameter when creating a User
62 63 64 |
# File 'lib/livejournal/basic.rb', line 62 def password @password end |
#server ⇒ Object
parameter when creating a User
62 63 64 |
# File 'lib/livejournal/basic.rb', line 62 def server @server end |
#usejournal ⇒ Object
Set usejournal to log in as user username but act as user usejournal. For example, to work with a community you own.
65 66 67 |
# File 'lib/livejournal/basic.rb', line 65 def usejournal @usejournal end |
#username ⇒ Object
parameter when creating a User
62 63 64 |
# File 'lib/livejournal/basic.rb', line 62 def username @username end |
Instance Method Details
#canonical_journal_name ⇒ Object
83 84 85 |
# File 'lib/livejournal/basic.rb', line 83 def canonical_journal_name journal.tr("_", "-") end |
#journal ⇒ Object
77 78 79 |
# File 'lib/livejournal/basic.rb', line 77 def journal @usejournal || @username end |
#journal_url ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/livejournal/basic.rb', line 86 def journal_url klass = server.use_ssl ? URI::HTTPS : URI::HTTP host = server.host.gsub(/^www\./, "") if journal[0] == "_" klass.build(host: "users.#{host}", port: server.port, path: "/" + canonical_journal_name).to_s else klass.build(host: "#{canonical_journal_name}.#{host}", port: server.port).to_s end end |
#to_s ⇒ Object
80 81 82 |
# File 'lib/livejournal/basic.rb', line 80 def to_s "#{@username}: '#{@fullname}'" end |