Class: Picard::MethodAst
Instance Method Summary collapse
- #all_statements_in_block(block_name) ⇒ Object
- #body_statements ⇒ Object
- #generate_method ⇒ Object
-
#initialize(ast) ⇒ MethodAst
constructor
A new instance of MethodAst.
- #replace_statement!(index, new_statement) ⇒ Object
Constructor Details
#initialize(ast) ⇒ MethodAst
Returns a new instance of MethodAst.
28 29 30 |
# File 'lib/picard/ast_helper.rb', line 28 def initialize ast @ast = ast end |
Instance Method Details
#all_statements_in_block(block_name) ⇒ Object
37 38 39 40 41 |
# File 'lib/picard/ast_helper.rb', line 37 def all_statements_in_block block_name statements = body_statements start_index = find_index_of_statements_calling(statements, block_name) start_index ? statements[start_index + 1 .. -1] : [] end |
#body_statements ⇒ Object
32 33 34 35 |
# File 'lib/picard/ast_helper.rb', line 32 def body_statements st = wrap_into_result_items(all_statements) remove_prefix_statement st end |
#generate_method ⇒ Object
47 48 49 50 |
# File 'lib/picard/ast_helper.rb', line 47 def generate_method str = ast_to_str(@ast) remove_spaces str end |
#replace_statement!(index, new_statement) ⇒ Object
43 44 45 |
# File 'lib/picard/ast_helper.rb', line 43 def replace_statement! index, new_statement all_statements[index] = new_statement end |