Class: KeepassKpscript::Select
- Inherits:
-
Object
- Object
- KeepassKpscript::Select
- Defined in:
- lib/keepass_kpscript/select.rb
Overview
Define rules to select entries from a Keepass database. Those rules are taken from keepass.info/help/v2_dev/scr_sc_index.html#editentry
Instance Method Summary collapse
-
#all ⇒ Object
Select all entries.
-
#expired(switch = true) ⇒ Object
Select entries that have expired.
-
#expires(switch = true) ⇒ Object
Select entries that expire.
-
#fields(selection) ⇒ Object
Select a set of given field values.
-
#group(group_name) ⇒ Object
Select entries that have a given parent group.
-
#group_path(*group_path_entries) ⇒ Object
Select entries that have a given group path.
-
#initialize ⇒ Select
constructor
Constructor.
-
#tags(*lst_tags) ⇒ Object
Select a list of tags.
-
#to_s ⇒ Object
Return the command-line string selecting the entries.
-
#uuid(id) ⇒ Object
Select a UUID.
Constructor Details
#initialize ⇒ Select
Constructor
8 9 10 |
# File 'lib/keepass_kpscript/select.rb', line 8 def initialize @selectors = [] end |
Instance Method Details
#all ⇒ Object
Select all entries
- Result
-
self: The selector itself, useful for chaining
95 96 97 98 |
# File 'lib/keepass_kpscript/select.rb', line 95 def all @selectors << '-refx-All' self end |
#expired(switch = true) ⇒ Object
Select entries that have expired
Parameters:
-
switch (Boolean): Do we select entries that have expired? [default = true]
- Result
-
self: The selector itself, useful for chaining
64 65 66 67 |
# File 'lib/keepass_kpscript/select.rb', line 64 def expired(switch = true) @selectors << "-refx-Expired:#{switch ? 'true' : 'false'}" self end |
#expires(switch = true) ⇒ Object
Select entries that expire
Parameters:
-
switch (Boolean): Do we select entries that expire? [default = true]
- Result
-
self: The selector itself, useful for chaining
53 54 55 56 |
# File 'lib/keepass_kpscript/select.rb', line 53 def expires(switch = true) @selectors << "-refx-Expires:#{switch ? 'true' : 'false'}" self end |
#fields(selection) ⇒ Object
Select a set of given field values
- Parameters
-
selection (Hash<String or Symbol, String>): Set of { field_name => field_value } to be selected.
- Result
-
self: The selector itself, useful for chaining
18 19 20 21 22 23 |
# File 'lib/keepass_kpscript/select.rb', line 18 def fields(selection) selection.each do |field_name, field_value| @selectors << "-ref-#{field_name}:\"#{field_value}\"" end self end |
#group(group_name) ⇒ Object
Select entries that have a given parent group
Parameters:
-
group_name (String): Name of the parent group
- Result
-
self: The selector itself, useful for chaining
75 76 77 78 |
# File 'lib/keepass_kpscript/select.rb', line 75 def group(group_name) @selectors << "-refx-Group:\"#{group_name}\"" self end |
#group_path(*group_path_entries) ⇒ Object
Select entries that have a given group path
Parameters:
-
group_path_entries (Array<String>): Group path
- Result
-
self: The selector itself, useful for chaining
86 87 88 89 |
# File 'lib/keepass_kpscript/select.rb', line 86 def group_path(*group_path_entries) @selectors << "-refx-GroupPath:\"#{group_path_entries.flatten.join('/')}\"" self end |
#tags(*lst_tags) ⇒ Object
Select a list of tags
- Parameters
-
lst_tags (Array<String>): List of tags to select
- Result
-
self: The selector itself, useful for chaining
42 43 44 45 |
# File 'lib/keepass_kpscript/select.rb', line 42 def (*) @selectors << "-refx-Tags:\"#{.flatten.join(',')}\"" self end |
#to_s ⇒ Object
Return the command-line string selecting the entries
- Result
-
String: The command-line string
104 105 106 |
# File 'lib/keepass_kpscript/select.rb', line 104 def to_s @selectors.join(' ') end |
#uuid(id) ⇒ Object
Select a UUID
- Parameters
-
id (String): The UUID
- Result
-
self: The selector itself, useful for chaining
31 32 33 34 |
# File 'lib/keepass_kpscript/select.rb', line 31 def uuid(id) @selectors << "-refx-UUID:#{id}" self end |