Class: Courgette::FileToSexpr
- Inherits:
-
Object
- Object
- Courgette::FileToSexpr
- Defined in:
- lib/courgette/file_to_sexpr.rb
Instance Method Summary collapse
- #convert(filename) ⇒ Object
-
#initialize ⇒ FileToSexpr
constructor
A new instance of FileToSexpr.
Constructor Details
#initialize ⇒ FileToSexpr
Returns a new instance of FileToSexpr.
5 6 7 |
# File 'lib/courgette/file_to_sexpr.rb', line 5 def initialize @parser = RubyParser.new end |
Instance Method Details
#convert(filename) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/courgette/file_to_sexpr.rb', line 9 def convert filename contents = File.read filename begin x = @parser.parse contents rescue Racc::ParseError, RubyParser::SyntaxError => e $stderr.puts "Error parsing #{filename}: #{e} (file ignored)" end end |