Class: JsDuck::Js::NodeArray
- Inherits:
 - 
      Object
      
        
- Object
 - JsDuck::Js::NodeArray
 
 
- Defined in:
 - lib/jsduck/js/node_array.rb
 
Overview
Wraps around array of AST nodes.
Instance Method Summary collapse
- 
  
    
      #[](i)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a child AST node as AstNode class.
 - 
  
    
      #each  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Iterates over all the AstNodes in array.
 - 
  
    
      #initialize(nodes)  ⇒ NodeArray 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
Initialized with array of AST Hashes from Esprima.
 - 
  
    
      #length  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
The length of array.
 - 
  
    
      #map  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Maps over all the AstNodes in array.
 
Constructor Details
#initialize(nodes) ⇒ NodeArray
Initialized with array of AST Hashes from Esprima.
      9 10 11  | 
    
      # File 'lib/jsduck/js/node_array.rb', line 9 def initialize(nodes) @nodes = nodes || [] end  | 
  
Instance Method Details
#[](i) ⇒ Object
Returns a child AST node as AstNode class.
      14 15 16  | 
    
      # File 'lib/jsduck/js/node_array.rb', line 14 def [](i) Js::Node.create(@nodes[i]) end  | 
  
#each ⇒ Object
Iterates over all the AstNodes in array.
      24 25 26  | 
    
      # File 'lib/jsduck/js/node_array.rb', line 24 def each @nodes.each {|p| yield(Js::Node.create(p)) } end  | 
  
#length ⇒ Object
The length of array
      19 20 21  | 
    
      # File 'lib/jsduck/js/node_array.rb', line 19 def length @nodes.length end  |