Class: Sexp
Instance Method Summary collapse
- #assertion ⇒ Object
- #assertion? ⇒ Boolean
- #d? ⇒ Boolean
-
#each_subexp(include_root = true) {|_self| ... } ⇒ Object
visit every node in the tree, including the root, that is an Sexp todo: test todo: use deep_each instead.
- #to_ruby ⇒ Object
Instance Method Details
#assertion ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/wrong/sexp_ext.rb', line 33 def assertion sexp = self assertion = if sexp.assertion? sexp else nested_assertions.first end assertion end |
#assertion? ⇒ Boolean
25 26 27 28 29 30 31 |
# File 'lib/wrong/sexp_ext.rb', line 25 def assertion? self.is_a? Sexp and self[0] == :iter and self[1].is_a? Sexp and self[1][0] == :call and Wrong.config.hidden_methods.include? self[1][2] end |
#d? ⇒ Boolean
6 7 8 9 10 11 |
# File 'lib/wrong/d.rb', line 6 def d? is_a?(Sexp) && (self[0] == :iter) && (self[1][0] == :call) && (self[1][2] == :d) end |
#each_subexp(include_root = true) {|_self| ... } ⇒ Object
visit every node in the tree, including the root, that is an Sexp todo: test todo: use deep_each instead
16 17 18 19 20 21 22 23 |
# File 'lib/wrong/sexp_ext.rb', line 16 def each_subexp(include_root = true, &block) yield self if include_root each do |child| if child.is_a?(Sexp) child.each_subexp(&block) end end end |
#to_ruby ⇒ Object
7 8 9 10 11 |
# File 'lib/wrong/sexp_ext.rb', line 7 def to_ruby sexp = self.deep_clone ruby = Ruby2Ruby.new.process(sexp) ruby end |