Class: Shh::Command::ListKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/shh/command/list_keys.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry, io) ⇒ ListKeys

Returns a new instance of ListKeys.



4
5
6
7
8
# File 'lib/shh/command/list_keys.rb', line 4

def initialize entry, io
  @entry, @io = entry, io
  @usage = "(<substring>)"
  @help = "Lists all keys for the entry or those including the specified substring"
end

Instance Attribute Details

#helpObject (readonly)

Returns the value of attribute help.



2
3
4
# File 'lib/shh/command/list_keys.rb', line 2

def help
  @help
end

#usageObject (readonly)

Returns the value of attribute usage.



2
3
4
# File 'lib/shh/command/list_keys.rb', line 2

def usage
  @usage
end

Instance Method Details

#execute(text = nil) ⇒ Object



10
11
12
13
14
15
# File 'lib/shh/command/list_keys.rb', line 10

def execute text=nil
  @entry.each_key do |key|
    next if text and !(key =~ /#{text}/)
    @io.say key
  end
end