Class: Sexp
- Inherits:
-
Object
- Object
- Sexp
- Defined in:
- lib/rp_extensions.rb,
lib/ruby_parser_extras.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #add_all(x) ⇒ Object
- #block_pass? ⇒ Boolean
- #check_line_numbers ⇒ Object
-
#line_min ⇒ Object
Returns the maximum line number of the children of self.
- #nil_line? ⇒ Boolean
- #to_sym ⇒ Object
- #value ⇒ Object
Instance Attribute Details
#paren ⇒ Object
45 46 47 |
# File 'lib/rp_extensions.rb', line 45 def paren @paren ||= false end |
Instance Method Details
#add_all(x) ⇒ Object
61 62 63 |
# File 'lib/rp_extensions.rb', line 61 def add_all x self.concat x.sexp_body end |
#block_pass? ⇒ Boolean
65 66 67 |
# File 'lib/rp_extensions.rb', line 65 def block_pass? any? { |s| Sexp === s && s.sexp_type == :block_pass } end |
#check_line_numbers ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/ruby_parser_extras.rb', line 10 def check_line_numbers raise "bad nil line for:\n%s" % [self.pretty_inspect] if nil_line? raise "bad line number for:\n%s" % [self.pretty_inspect] unless Integer === self.line && self.line >= 1 && self.line <= self.line_min end |
#line_min ⇒ Object
Returns the maximum line number of the children of self.
21 22 23 |
# File 'lib/ruby_parser_extras.rb', line 21 def line_min @line_min ||= [self.deep_each.map(&:line).min, self.line].compact.min end |
#nil_line? ⇒ Boolean
25 26 27 |
# File 'lib/ruby_parser_extras.rb', line 25 def nil_line? self.deep_each.map(&:line).any?(&:nil?) end |
#to_sym ⇒ Object
54 55 56 57 |
# File 'lib/rp_extensions.rb', line 54 def to_sym raise "no: #{self.inspect}.to_sym is a bug" self.value.to_sym end |
#value ⇒ Object
49 50 51 52 |
# File 'lib/rp_extensions.rb', line 49 def value raise "multi item sexp" if size > 2 last end |