Class: Bio::NeXML::Parser
- Inherits:
- 
      Object
      
        - Object
- Bio::NeXML::Parser
 
- Defined in:
- lib/bio/db/nexml/parser.rb
Overview
end
Instance Method Summary collapse
- 
  
    
      #close  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Close the assosicated XML::Reader object and try to free other resources like @nexml. 
- 
  
    
      #initialize(nexml, validate = false)  ⇒ Parser 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Parser. 
- 
  
    
      #parse  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Is a factory method that returns an object of class Bio::NeXML::Nexml. 
Constructor Details
#initialize(nexml, validate = false) ⇒ Parser
Returns a new instance of Parser.
| 14 15 16 17 18 19 20 21 22 23 24 | # File 'lib/bio/db/nexml/parser.rb', line 14 def initialize( nexml, validate = false ) #initialize a cache @cache = {} #initialize a libxml cursor @reader = read( nexml ) #validate validate_nexml if validate end | 
Instance Method Details
#close ⇒ Object
Close the assosicated XML::Reader object and try to free other resources like @nexml
| 63 64 65 | # File 'lib/bio/db/nexml/parser.rb', line 63 def close @reader.close end | 
#parse ⇒ Object
Is a factory method that returns an object of class Bio::NeXML::Nexml
| 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | # File 'lib/bio/db/nexml/parser.rb', line 28 def parse #return a cached version if it exists return @nexml if @nexml #start at the root element skip_leader #start with a new Nexml object version = attribute( 'version' ) generator = attribute( 'generator' ) @nexml = NeXML::Nexml.new( version, generator ) #perhaps a namespace api as well #start parsing other elements while next_node case local_name when "otus" @nexml.add_otus( parse_otus ) when "trees" @nexml.add_trees( parse_trees ) when "characters" @nexml.add_characters( parse_characters ) end end #close the libxml parser object #close #return the Nexml object @nexml end |