Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- def function_for_1
- puts "hey, i'm being called in block one"
- end
- def function_for_2
- puts "hey, i'm being called in block two"
- end
- currently_in_cmd = false
- last_command_block = ""
- STDIN.read.split("\n").each do |a|
- 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(" ","_")}")
- else
- puts "COMMAND ENCOUNTERD OUTSIDE COMMAND BLOCK"
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement