Class: Shh::Command::OpenEntry
- Inherits:
-
Object
- Object
- Shh::Command::OpenEntry
- Defined in:
- lib/shh/command/open_entry.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
- #completion(text) ⇒ Object
- #execute(name = nil) ⇒ Object
-
#initialize(repository, io) ⇒ OpenEntry
constructor
A new instance of OpenEntry.
Constructor Details
#initialize(repository, io) ⇒ OpenEntry
Returns a new instance of OpenEntry.
7 8 9 10 11 |
# File 'lib/shh/command/open_entry.rb', line 7 def initialize repository, io @repository, @io = repository, io @usage = "<entry name>" @help = "Enters a subshell for editing the specifed entry" end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
5 6 7 |
# File 'lib/shh/command/open_entry.rb', line 5 def help @help end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/shh/command/open_entry.rb', line 5 def usage @usage end |
Instance Method Details
#completion(text) ⇒ Object
13 14 15 |
# File 'lib/shh/command/open_entry.rb', line 13 def completion text @repository.map{|entry| entry['name']}.grep(/^#{text}/).sort || [] end |
#execute(name = nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/shh/command/open_entry.rb', line 17 def execute name=nil return unless name return if name.empty? entry = @repository.find { |entry| entry['name'] == name } entry ||= {'name' => name, 'id' => UUIDTools::UUID.random_create.to_s } Shh::EntryMenu.new(@io, entry).push @repository[entry['id']] = entry end |