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