Class: VirtualKeywords::ParseTreeStrategy
- Inherits:
-
Object
- Object
- VirtualKeywords::ParseTreeStrategy
- Defined in:
- lib/virtual_keywords/parser_strategy.rb
Overview
Parser strategy that uses ParseTree
Instance Method Summary collapse
-
#initialize(parse_tree, sexp_processor) ⇒ ParseTreeStrategy
constructor
Initialize a ParseTreeStrategy.
-
#translate_instance_method(klass, method_name) ⇒ Object
Translate an instance method of a class.
Constructor Details
#initialize(parse_tree, sexp_processor) ⇒ ParseTreeStrategy
Initialize a ParseTreeStrategy
Arguments:
parse_tree: (Class) an instance of the ParseTree singleton, that
translates code into ParseTree output.
sexp_processor: (SexpProcessor) an object that translates ParseTree
output into rewriteable sexps.
31 32 33 34 |
# File 'lib/virtual_keywords/parser_strategy.rb', line 31 def initialize(parse_tree, sexp_processor) @parse_tree = parse_tree @sexp_processor = sexp_processor end |
Instance Method Details
#translate_instance_method(klass, method_name) ⇒ Object
Translate an instance method of a class.
Arguments:
klass: (Class) the class.
method_name: (String) the name of the method to translate.
Returns:
(Sexp) the method, turned into a sexp.
44 45 46 |
# File 'lib/virtual_keywords/parser_strategy.rb', line 44 def translate_instance_method(klass, method_name) @sexp_processor.process(@parse_tree.translate(klass, method_name)) end |