Class: Lastpass::Account
- Inherits:
-
Object
- Object
- Lastpass::Account
- Defined in:
- lib/lastpass-api/account.rb
Instance Attribute Summary collapse
-
#group ⇒ Object
readonly
TODO: Make group editable eventually.
-
#id ⇒ Object
readonly
TODO: Make group editable eventually.
-
#name ⇒ Object
Returns the value of attribute name.
-
#notes ⇒ Object
Returns the value of attribute notes.
-
#password ⇒ Object
Returns the value of attribute password.
-
#url ⇒ Object
Returns the value of attribute url.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(params) ⇒ Account
constructor
A new instance of Account.
-
#inspect ⇒ Object
Hide instance variables and values.
-
#save ⇒ Object
TODO: This does not support changing groups yet!.
- #to_hash ⇒ Object (also: #to_h)
- #update(params) ⇒ Object
Constructor Details
#initialize(params) ⇒ Account
Returns a new instance of Account.
6 7 8 |
# File 'lib/lastpass-api/account.rb', line 6 def initialize( params ) params_to_account( params ) end |
Instance Attribute Details
#group ⇒ Object (readonly)
TODO: Make group editable eventually
3 4 5 |
# File 'lib/lastpass-api/account.rb', line 3 def group @group end |
#id ⇒ Object (readonly)
TODO: Make group editable eventually
3 4 5 |
# File 'lib/lastpass-api/account.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/lastpass-api/account.rb', line 4 def name @name end |
#notes ⇒ Object
Returns the value of attribute notes.
4 5 6 |
# File 'lib/lastpass-api/account.rb', line 4 def notes @notes end |
#password ⇒ Object
Returns the value of attribute password.
4 5 6 |
# File 'lib/lastpass-api/account.rb', line 4 def password @password end |
#url ⇒ Object
Returns the value of attribute url.
4 5 6 |
# File 'lib/lastpass-api/account.rb', line 4 def url @url end |
#username ⇒ Object
Returns the value of attribute username.
4 5 6 |
# File 'lib/lastpass-api/account.rb', line 4 def username @username end |
Instance Method Details
#delete ⇒ Object
44 45 46 47 |
# File 'lib/lastpass-api/account.rb', line 44 def delete Cli.rm( @id ) @deleted = true end |
#inspect ⇒ Object
Hide instance variables and values
64 65 66 67 |
# File 'lib/lastpass-api/account.rb', line 64 def inspect original_inspect = super original_inspect.split( ' ' ).first << '>' end |
#save ⇒ Object
TODO: This does not support changing groups yet!
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/lastpass-api/account.rb', line 19 def save deleted! if @deleted # If there is an ID, update that entry if @id Cli.edit( @id, name: @name, username: @username, password: @password, url: @url, notes: @notes, group: @group ) else # If no ID, that means this is a new entry Cli.add( @name, username: @username, password: @password, url: @url, notes: @notes, group: @group ) set_id_after_save end self end |
#to_hash ⇒ Object Also known as: to_h
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/lastpass-api/account.rb', line 49 def to_hash params = {} params[:id] = @id if @id params[:name] = @name if @name params[:username] = @username if @username params[:password] = @password if @password params[:url] = @url if @url params[:notes] = @notes if @notes params[:group] = @group if @group params end |
#update(params) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/lastpass-api/account.rb', line 10 def update( params ) deleted! if @deleted params.delete( :id ) # Prevent overwriting ID params.delete( :group ) # Prevent overwriting group params_to_account( params ) save end |