Class: Rednode::Process
- Inherits:
-
EventEmitter
- Object
- EventEmitter
- Rednode::Process
- Defined in:
- lib/rednode/process.rb
Defined Under Namespace
Constant Summary collapse
- EventEmitter =
self.superclass
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#global ⇒ Object
readonly
Returns the value of attribute global.
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Attributes inherited from EventEmitter
Instance Method Summary collapse
- #_byteLength(str, encoding = 'utf8') ⇒ Object
- #_needTickCallback(*args) ⇒ Object
- #argv ⇒ Object
- #binding(id) ⇒ Object
- #chdir(dirname) ⇒ Object
- #compile(source, filename) ⇒ Object
- #cwd(*args) ⇒ Object
- #dlopen(filename, exports) ⇒ Object
-
#initialize(node) ⇒ Process
constructor
A new instance of Process.
- #loop(*args) ⇒ Object
- #Timer ⇒ Object
- #umask(mask = nil) ⇒ Object
-
#version ⇒ Object
TODO: find a good place to read this.
Methods included from Namespace
Methods included from Constants
Methods inherited from EventEmitter
Constructor Details
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
6 7 8 |
# File 'lib/rednode/process.rb', line 6 def env @env end |
#global ⇒ Object (readonly)
Returns the value of attribute global.
6 7 8 |
# File 'lib/rednode/process.rb', line 6 def global @global end |
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
6 7 8 |
# File 'lib/rednode/process.rb', line 6 def scheduler @scheduler end |
Instance Method Details
#_byteLength(str, encoding = 'utf8') ⇒ Object
50 51 52 53 |
# File 'lib/rednode/process.rb', line 50 def _byteLength(str, encoding = 'utf8') chars = encoding == 'utf8' ? str.unpack('C*') : str.unpack('U*') chars.length end |
#_needTickCallback(*args) ⇒ Object
72 73 74 75 76 |
# File 'lib/rednode/process.rb', line 72 def _needTickCallback(*args) @scheduler.next_tick do @node.engine.eval("process._tickCallback()") end end |
#argv ⇒ Object
38 39 40 |
# File 'lib/rednode/process.rb', line 38 def argv ['rednode', @node.main] end |
#binding(id) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rednode/process.rb', line 17 def binding(id) if @bindings[id] @bindings[id] elsif Rednode::Bindings::const_defined?(pascalize(id)) @bindings[id] = Rednode::Bindings::const_get(pascalize(id)).new elsif id == "natives" exports = @engine['Object'].new for native in Dir["#{NODE_HOME}/lib/*.js"] File.basename(native) =~ /^(.*)\.js$/ exports[$1] = File.read(native) end @bindings[id] = exports else raise "no such module: #{id}" end end |
#chdir(dirname) ⇒ Object
46 47 48 |
# File 'lib/rednode/process.rb', line 46 def chdir(dirname) Dir.chdir(dirname) end |
#compile(source, filename) ⇒ Object
34 35 36 |
# File 'lib/rednode/process.rb', line 34 def compile(source, filename) @engine.eval(source, filename) end |
#cwd(*args) ⇒ Object
42 43 44 |
# File 'lib/rednode/process.rb', line 42 def cwd(*args) Dir.pwd end |
#dlopen(filename, exports) ⇒ Object
64 65 66 |
# File 'lib/rednode/process.rb', line 64 def dlopen(filename, exports) raise "Rednode currently can't read native (.node) modules. Failed to load: #{filename}" end |
#loop(*args) ⇒ Object
60 61 62 |
# File 'lib/rednode/process.rb', line 60 def loop(*args) @scheduler.start_loop end |
#Timer ⇒ Object
105 106 107 |
# File 'lib/rednode/process.rb', line 105 def Timer @timer ||= lambda { Process::Timer.new(self) } end |
#umask(mask = nil) ⇒ Object
68 69 70 |
# File 'lib/rednode/process.rb', line 68 def umask(mask = nil) mask ? File.umask(mask) : File.umask end |
#version ⇒ Object
TODO: find a good place to read this.
56 57 58 |
# File 'lib/rednode/process.rb', line 56 def version "0.2.0" end |