Class: Lastpass::Group
- Inherits:
-
Object
- Object
- Lastpass::Group
- Defined in:
- lib/lastpass-api/group.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #delete ⇒ Object
-
#initialize(params) ⇒ Group
constructor
A new instance of Group.
-
#inspect ⇒ Object
Hide instance variables and values.
- #save ⇒ Object
- #to_hash ⇒ Object (also: #to_h)
- #update(params) ⇒ Object
Constructor Details
#initialize(params) ⇒ Group
Returns a new instance of Group.
6 7 8 9 |
# File 'lib/lastpass-api/group.rb', line 6 def initialize( params ) params[:name].chomp!( '/' ) if params[:name]&.end_with? '/' params_to_group( params ) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/lastpass-api/group.rb', line 3 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/lastpass-api/group.rb', line 4 def name @name end |
Instance Method Details
#delete ⇒ Object
30 31 32 33 |
# File 'lib/lastpass-api/group.rb', line 30 def delete Cli.rm( @id ) @deleted = true end |
#inspect ⇒ Object
Hide instance variables and values
45 46 47 48 |
# File 'lib/lastpass-api/group.rb', line 45 def inspect original_inspect = super original_inspect.split( ' ' ).first << '>' end |
#save ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/lastpass-api/group.rb', line 18 def save deleted! if @deleted # If there is an ID, update that entry if @id Cli.edit_group( @id, name: @name ) else # If no ID, that means this is a new entry Cli.add_group( @name ) set_id_after_save end self end |
#to_hash ⇒ Object Also known as: to_h
35 36 37 38 39 40 |
# File 'lib/lastpass-api/group.rb', line 35 def to_hash params = {} params[:id] = @id if @id params[:name] = @name if @name params end |
#update(params) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/lastpass-api/group.rb', line 11 def update( params ) deleted! if @deleted params.delete( :id ) # Prevent overwriting ID params_to_group( params ) save end |