Method: Sexp#array_size
- Defined in:
- lib/code_analyzer/sexp.rb
#array_size ⇒ Integer
Get the array size.
s(:array,
s(:args_add,
s(:args_add, s(:args_new), s(:string_literal, s(:string_add, s(:string_content), s(:@tstring_content, "first_name", s(1, 2))))),
s(:string_literal, s(:string_add, s(:string_content), s(:@tstring_content, "last_name", s(1, 16))))
)
)
=> 2
727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 |
# File 'lib/code_analyzer/sexp.rb', line 727 def array_size if :array == sexp_type first_node = self[1] array_size = 0 if first_node while true array_size += 1 first_node = s(:args_new) == first_node[1] ? first_node[2] : first_node[1] if :args_add != first_node.sexp_type array_size += first_node.array_size if :array == first_node.sexp_type break end end end array_size end end |