123456789_123456789_123456789_123456789_123456789_

Module: RuboCop::Cop::TrailingBody

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Extended In:
Included In:
Defined in: lib/rubocop/cop/mixin/trailing_body.rb

Overview

Common methods shared by TrailingBody cops

Instance Method Summary

Instance Method Details

#body_on_first_line?(node, body) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/trailing_body.rb', line 12

def body_on_first_line?(node, body)
  same_line?(node, body)
end

#first_part_of(body)

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/trailing_body.rb', line 16

def first_part_of(body)
  if body.begin_type?
    body.children.first.source_range
  else
    body.source_range
  end
end

#trailing_body?(node) ⇒ Boolean

[ GitHub ]

  
# File 'lib/rubocop/cop/mixin/trailing_body.rb', line 7

def trailing_body?(node)
  body = node.to_a.reverse[0]
  body && node.multiline? && body_on_first_line?(node, body)
end