Class: SSHake::Mock::CommandSet
- Inherits:
-
Object
- Object
- SSHake::Mock::CommandSet
- Defined in:
- lib/sshake/mock/command_set.rb
Instance Method Summary collapse
- #add(matcher, &block) ⇒ Object
-
#initialize ⇒ CommandSet
constructor
A new instance of CommandSet.
- #match(given_command) ⇒ Object
Constructor Details
#initialize ⇒ CommandSet
Returns a new instance of CommandSet.
9 10 11 |
# File 'lib/sshake/mock/command_set.rb', line 9 def initialize @commands = [] end |
Instance Method Details
#add(matcher, &block) ⇒ Object
13 14 15 16 17 |
# File 'lib/sshake/mock/command_set.rb', line 13 def add(matcher, &block) command = Command.new(matcher, &block) @commands << command command end |
#match(given_command) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/sshake/mock/command_set.rb', line 19 def match(given_command) @commands.each do |command| if matches = command.match(given_command) return [command, matches] end end nil end |