Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- def function_for_1(payload)
- puts "hey, i'm being called in block one"
- puts payload
- end
- def function_for_2(payload)
- puts "hey, i'm being called in block two"
- puts payload
- end
- currently_in_cmd = false
- last_command_block = ""
- while a = gets
- case a
- when /cmd([0-9]+)-start/
- puts "Entering Command #{$1}"
- last_command_block = $1
- currently_in_cmd = true
- when /cmd[0-9]+-stop/
- puts "Exiting command #{a}"
- currently_in_cmd = false
- else
- if currently_in_cmd
- puts "CMD[#{last_command_block}]:running command: #{a}"
- send("function_for_#{last_command_block.gsub(" ","_")}", a)
- else
- puts "COMMAND ENCOUNTERD OUTSIDE COMMAND BLOCK"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement