Module: Kernel
- Defined in:
- opal/stdlib/pp.rb,
opal/stdlib/native.rb,
opal/stdlib/pathname.rb,
opal/stdlib/opal-parser.rb
Instance Method Summary collapse
- #Array(object, *args, &block) ⇒ Object
- #eval(str) ⇒ Object
- #Native(obj) ⇒ Object
- #native?(value) ⇒ Boolean
- #Pathname(path) ⇒ Object
- #pretty_inspect ⇒ Object
- #require_remote(url) ⇒ Object
Instance Method Details
#Array(object, *args, &block) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'opal/stdlib/native.rb', line 144 def Array(object, *args, &block) %x{ if (object == null || object === nil) { return []; } else if (#{native?(object)}) { return #{Native::Array.new(object, *args, &block).to_a}; } else if (#{object.respond_to? :to_ary}) { return #{object.to_ary}; } else if (#{object.respond_to? :to_a}) { return #{object.to_a}; } else { return [object]; } } end |
#eval(str) ⇒ Object
7 8 9 10 |
# File 'opal/stdlib/opal-parser.rb', line 7 def eval(str) code = Opal.compile str `eval(#{code})` end |
#Native(obj) ⇒ Object
134 135 136 137 138 139 140 141 142 |
# File 'opal/stdlib/native.rb', line 134 def Native(obj) if `#{obj} == null` nil elsif native?(obj) Native::Object.new(obj) else obj end end |
#native?(value) ⇒ Boolean
130 131 132 |
# File 'opal/stdlib/native.rb', line 130 def native?(value) `value == null || !value._klass` end |
#Pathname(path) ⇒ Object
29 30 |
# File 'opal/stdlib/pathname.rb', line 29 def Pathname(path) end |
#pretty_inspect ⇒ Object
2 |
# File 'opal/stdlib/pp.rb', line 2 def pretty_inspect; inspect; end |
#require_remote(url) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'opal/stdlib/opal-parser.rb', line 12 def require_remote url %x{ var r = new XMLHttpRequest(); r.open("GET", url, false); r.send(''); } eval `r.responseText` end |