Class: Lastpass::Groups
- Inherits:
-
Collection
- Object
- Collection
- Lastpass::Groups
- Defined in:
- lib/lastpass-api/groups.rb
Overview
Interact with Lastpass groups/folders
Instance Method Summary collapse
-
#create(params) ⇒ Lastpass::Group
Create a new group.
-
#find(search_text, with_password: false) ⇒ Lastpass::Group, NilClass
Find a specific group by name or by ID.
-
#find_all(search_text = '.*', with_passwords: false) ⇒ Array<Lastpass::Group>
Find all groups by name or by ID.
-
#inspect ⇒ Object
private
Hide instance variables and values.
Instance Method Details
#create(params) ⇒ Lastpass::Group
Create a new group
54 55 56 57 |
# File 'lib/lastpass-api/groups.rb', line 54 def create( params ) params.delete( :id ) # Prevent overwriting ID Group.new( params ).save end |
#find(search_text, with_password: false) ⇒ Lastpass::Group, NilClass
Find a specific group by name or by ID
17 18 19 20 21 22 23 24 |
# File 'lib/lastpass-api/groups.rb', line 17 def find( search_text, with_password: false ) search_text.to_s.gsub!( '/', '' ) search_text << '/' unless is_number?( search_text ) params = super if params.is_a?( Hash ) && params[:name]&.end_with?( '/' ) Group.new( params ) end end |
#find_all(search_text = '.*', with_passwords: false) ⇒ Array<Lastpass::Group>
Note:
By default, with no params specified, all groups will be returned.
Find all groups by name or by ID
40 41 42 43 44 45 |
# File 'lib/lastpass-api/groups.rb', line 40 def find_all( search_text = '.*', with_passwords: false ) groups = super.select { |params| params[:name]&.end_with? '/' } groups.map do |params| Group.new( params ) end end |
#inspect ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Hide instance variables and values
62 63 64 65 |
# File 'lib/lastpass-api/groups.rb', line 62 def inspect original_inspect = super original_inspect.split( ' ' ).first << '>' end |