Class: SexpFactory
- Inherits:
-
Object
- Object
- SexpFactory
- Defined in:
- lib/sexp_factory.rb
Overview
SexpFactory generates a Sexp object from a given file and for a given type. The only supported type so far is Ruby (.rb) files.
Instance Method Summary collapse
-
#get_sexp(program, ext) ⇒ Object
- Returns a Sexp representation of the program =
Sexp
Params:program
- string containing a program to be converted to s-expression
ext
-
string for file extensions of the program.
- string containing a program to be converted to s-expression
- Returns a Sexp representation of the program =
-
#initialize ⇒ SexpFactory
constructor
A new instance of SexpFactory.
Constructor Details
#initialize ⇒ SexpFactory
Returns a new instance of SexpFactory.
6 7 8 9 10 |
# File 'lib/sexp_factory.rb', line 6 def initialize @ext_map = Hash.new rb_parser = RubyParser.new @ext_map['rb'] = lambda { |program| rb_parser.parse program } end |
Instance Method Details
#get_sexp(program, ext) ⇒ Object
Returns a Sexp representation of the program
Sexp
Params:
program
-
string containing a program to be converted to s-expression
ext
-
string for file extensions of the program
17 18 19 |
# File 'lib/sexp_factory.rb', line 17 def get_sexp program, ext @ext_map[ext].call program end |