ruby_command
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | ruby_command [2007/02/20 03:54] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | #$EPIC: ruby_command.txt, | ||
+ | ======Synopsis: | ||
+ | [[ruby_command|ruby]] {//ruby statement// | ||
+ | |||
+ | ======Purpose: | ||
+ | If the client was linked with an embedded ruby interpreter, | ||
+ | statement// | ||
+ | shall be executed by ruby. If the client was not linked against ruby, then no | ||
+ | action shall take place. | ||
+ | |||
+ | Although every //ruby statement// resolves to a (ruby) scalar value, that | ||
+ | (ruby) scalar value is discarded when you run it this way. | ||
+ | |||
+ | If the //ruby statement// has an error, the result is undefined, but usually | ||
+ | an error message is output to the window. | ||
+ | |||
+ | Remember that the insides of {}s are protected from ircII expansion, so if | ||
+ | you want to pass ircII values into your ruby script, you do best to export | ||
+ | the value to ruby using $[[ruby function]]() first. | ||
+ | should be a literal segment of ruby code. | ||
+ | |||
+ | You can call back to the client from ruby: | ||
+ | |EPIC.echo(string) | Output something on the epic window. | | ||
+ | |EPIC.say(string) | ||
+ | |EPIC.cmd(string) | ||
+ | |EPIC.eval(string) | Run " | ||
+ | |EPIC.expr(string) | Return value of epic expression " | ||
+ | |EPIC.call(string) | Call an epic function: string must be of the form " | ||
+ | |||
+ | You are permitted to register ruby END blocks. | ||
+ | initiates shutdown procedures. | ||
+ | |||
+ | It is important to remember that to ruby, everything in ircII is a String | ||
+ | object. | ||
+ | the value contains an integer, you must cast it (with .to_i). | ||
+ | |||
+ | It is important to remember that ruby is less tolerant of rogue semicolons | ||
+ | than ircII is. You do not want to mix the standard loader with ruby. Use | ||
+ | the PF loader for everything, to avoid unnecessary insertion of semicolons. | ||
+ | |||
+ | ======Examples: | ||
+ | < | ||
+ | Assign to the epic variable $epicvar the value of the ruby variable " | ||
+ | RUBY { EPIC.expr(" | ||
+ | |||
+ | Assign to the ruby variable " | ||
+ | RUBY { rubyvar = EPIC.expr(" | ||
+ | |||
+ | Run /EPIC_ALIAS five times, passing it each number 1 to 5. | ||
+ | RUBY { | ||
+ | 1.upto(5) {|x| | ||
+ | EPIC.cmd(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Iterate over each item in ruby collection, passing each value to epic alias: | ||
+ | RUBY { | ||
+ | something.each {|x| | ||
+ | EPIC.cmd(" | ||
+ | } | ||
+ | } | ||
+ | |||
+ | Assign a value to a local variable, manipulate it in ruby, and pass it back: | ||
+ | alias booya { | ||
+ | @ :epiclocal = 5 | ||
+ | ruby { | ||
+ | rubyvar = EPIC.expr(" | ||
+ | rubyvar = rubyvar + 1 | ||
+ | EPIC.expr(" | ||
+ | } | ||
+ | echo $epiclocal | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ======History: | ||
+ | The [[ruby command]] first appeared in EPIC5-0.3.1. | ||
ruby_command.txt · Last modified: 2007/02/20 03:54 by 127.0.0.1