Module: Opal::Env::System
Instance Method Summary collapse
-
#array(*args) ⇒ Object
Shortcut for making arrays.
-
#block(code) ⇒ Object
Shortcut for making blocks.
-
#get ⇒ Object
Shortcut for Ruby “$stdin.readline”.
-
#import(name) ⇒ Object
Shortcut for Ruby “require”.
-
#namespace(n) ⇒ Object
Shortcut for making classes (Opal: Namespaces).
-
#namespace_def(ns, nm, code, *argnm) ⇒ Object
Shortcut for defining methods under classes (Opal: Namespaces).
-
#out(s) ⇒ Object
Shortcut for Ruby “print”.
-
#put(s) ⇒ Object
Shortcut for Ruby “puts”.
-
#quit ⇒ Object
Quit.
-
#run(s) ⇒ Object
Equal to “IO.popen”.
-
#tin ⇒ Object
Shortcut for Ruby “$stdin.read”.
-
#version ⇒ Object
Shortcut to “version”.
Instance Method Details
#array(*args) ⇒ Object
Shortcut for making arrays.
225 226 227 |
# File 'lib/opal.rb', line 225 def array(*args) return args end |
#block(code) ⇒ Object
Shortcut for making blocks.
235 236 237 238 239 |
# File 'lib/opal.rb', line 235 def block(code) return proc do Opal.opal_eval code end end |
#get ⇒ Object
Shortcut for Ruby “$stdin.readline”.
220 221 222 |
# File 'lib/opal.rb', line 220 def get return $stdin.readline end |
#import(name) ⇒ Object
Shortcut for Ruby “require”.
230 231 232 |
# File 'lib/opal.rb', line 230 def import(name) require name.to_s end |
#namespace(n) ⇒ Object
Shortcut for making classes (Opal: Namespaces).
242 243 244 |
# File 'lib/opal.rb', line 242 def namespace(n) return eval("Opal::Env::#{n.to_s} = Class.new") end |
#namespace_def(ns, nm, code, *argnm) ⇒ Object
Shortcut for defining methods under classes (Opal: Namespaces).
247 248 249 |
# File 'lib/opal.rb', line 247 def namespace_def(ns, nm, code, *argnm) eval("Opal::Env::#{ns.to_s}.class_eval do\ndef #{nm.to_s}(#{argnm.join(", ")})\n#{code}\nend\nend") end |
#out(s) ⇒ Object
Shortcut for Ruby “print”.
205 206 207 |
# File 'lib/opal.rb', line 205 def out(s) print s end |
#put(s) ⇒ Object
Shortcut for Ruby “puts”.
210 211 212 |
# File 'lib/opal.rb', line 210 def put(s) puts s end |
#run(s) ⇒ Object
Equal to “IO.popen”.
252 253 254 |
# File 'lib/opal.rb', line 252 def run(s) IO.popen(s).read end |
#tin ⇒ Object
Shortcut for Ruby “$stdin.read”.
215 216 217 |
# File 'lib/opal.rb', line 215 def tin return $stdin.read end |