Class: NCBO::Parser::BaseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/ncbo_resource_index/parser.rb

Direct Known Subclasses

ResourceIndex

Instance Method Summary collapse

Instance Method Details

#parse_xml(xml) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/ncbo_resource_index/parser.rb', line 5

def parse_xml(xml)
  if xml.kind_of?(String)
    parser = XML::Parser.string(xml, :options => LibXML::XML::Parser::Options::NOBLANKS)
  else
    parser = XML::Parser.io(xml, :options => LibXML::XML::Parser::Options::NOBLANKS)
  end
  parser.parse
end

#safe_to_i(str) ⇒ Object



14
15
16
# File 'lib/ncbo_resource_index/parser.rb', line 14

def safe_to_i(str)
  Integer(str) rescue str
end