Class: Shh::Command::ListEntries
- Inherits:
-
Object
- Object
- Shh::Command::ListEntries
- Defined in:
- lib/shh/command/list_entries.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #execute(text = nil) ⇒ Object
-
#initialize(repository, io) ⇒ ListEntries
constructor
A new instance of ListEntries.
Constructor Details
#initialize(repository, io) ⇒ ListEntries
Returns a new instance of ListEntries.
4 5 6 7 8 |
# File 'lib/shh/command/list_entries.rb', line 4 def initialize repository, io @repository, @io = repository, io @usage = "(<substring>)" @help = "Lists all entries or those with a name including the specified substring" end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
2 3 4 |
# File 'lib/shh/command/list_entries.rb', line 2 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
2 3 4 |
# File 'lib/shh/command/list_entries.rb', line 2 def usage @usage end |
Instance Method Details
#execute(text = nil) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/shh/command/list_entries.rb', line 10 def execute text=nil @repository.each do |entry| unless entry.id == entry['id'] puts "Encryption failure! Did you enter the correct password?" return end end @repository.sort{|l,r| (l['name']) <=> (r['name'])}.each do |entry| description = "#{entry['name']} (#{entry.id})" next if text and !(description =~ /#{text}/) @io.say description end end |