Class: Sexp

Inherits:
Object
  • Object
show all
Defined in:
lib/rp_extensions.rb,
lib/ruby_parser_extras.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#parenObject



43
44
45
# File 'lib/rp_extensions.rb', line 43

def paren
  @paren ||= false
end

Instance Method Details

#block_pass?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/rp_extensions.rb', line 47

def block_pass?
  any? { |s| Sexp === s && s.sexp_type == :block_pass }
end

#check_line_numbersObject



12
13
14
15
16
17
18
# File 'lib/ruby_parser_extras.rb', line 12

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_minObject

Returns the minimum line number of the children of self.



23
24
25
# File 'lib/ruby_parser_extras.rb', line 23

def line_min
  @line_min ||= [self.deep_each.map(&:line).min, self.line].compact.min
end

#nil_line?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ruby_parser_extras.rb', line 27

def nil_line?
  self.deep_each.map(&:line).any?(&:nil?)
end