Class: Array
- Defined in:
- opal/stdlib/pp.rb,
 opal/stdlib/json.rb,
 opal/stdlib/await.rb,
 opal/stdlib/native.rb,
 opal/stdlib/shellwords.rb
Overview
:nodoc:
Instance Method Summary collapse
- #each_await(&block) ⇒ Object
- #map_await(&block) ⇒ Object
- 
  
    
      #pretty_print(q)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    :nodoc:. 
- 
  
    
      #pretty_print_cycle(q)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    :nodoc:. 
- 
  
    
      #shelljoin  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    call-seq: array.shelljoin => string. 
- #to_json ⇒ Object
- 
  
    
      #to_n  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Retuns a copy of itself trying to call #to_n on each member. 
Instance Method Details
#each_await(&block) ⇒ Object
| 22 23 24 25 26 27 28 29 | # File 'opal/stdlib/await.rb', line 22 def each_await(&block) i = 0 while i < `self.length` yield(self[i]).await i += 1 end self end | 
#map_await(&block) ⇒ Object
| 12 13 14 15 16 17 18 19 20 | # File 'opal/stdlib/await.rb', line 12 def map_await(&block) i = 0 results = [] while i < `self.length` results << yield(self[i]).await i += 1 end results end | 
#pretty_print(q) ⇒ Object
:nodoc:
| 352 353 354 355 356 357 358 | # File 'opal/stdlib/pp.rb', line 352 def pretty_print(q) # :nodoc: q.group(1, '[', ']') { q.seplist(self) {|v| q.pp v } } end | 
#pretty_print_cycle(q) ⇒ Object
:nodoc:
| 360 361 362 | # File 'opal/stdlib/pp.rb', line 360 def pretty_print_cycle(q) # :nodoc: q.text(empty? ? '[]' : '[...]') end | 
#shelljoin ⇒ Object
call-seq: array.shelljoin => string
Builds a command line string from an argument list +array+ joining all elements escaped for the Bourne shell and separated by a space.
See Shellwords.shelljoin for details.
| 237 238 239 | # File 'opal/stdlib/shellwords.rb', line 237 def shelljoin Shellwords.join(self) end | 
#to_json ⇒ Object
| 136 137 138 139 140 141 142 143 144 145 146 | # File 'opal/stdlib/json.rb', line 136 def to_json %x{ var result = []; for (var i = 0, length = #{self}.length; i < length; i++) { result.push(#{`self[i]`.to_json}); } return '[' + result.join(',') + ']'; } end | 
#to_n ⇒ Object
Retuns a copy of itself trying to call #to_n on each member.
| 498 499 500 501 502 503 504 505 506 507 508 509 510 | # File 'opal/stdlib/native.rb', line 498 def to_n %x{ var result = []; for (var i = 0, length = self.length; i < length; i++) { var obj = self[i]; result.push(#{Native.try_convert(`obj`, `obj`)}); } return result; } end |