Module: RuboCop::AST::Ext::Range
Relationships & Source Files | |
Defined in: | lib/rubocop/ast/ext/range.rb |
Overview
Extensions to Parser::AST::Range
Instance Method Summary
-
#line_span(exclude_end: false) ⇒ Range
If
exclude_end
istrue
, then the range will be exclusive.
Instance Method Details
#line_span(exclude_end: false) ⇒ Range
If exclude_end
is true
, then the range will be exclusive.
Assume that node
corresponds to the following array literal:
[
:foo,
:
]
node.loc.begin.line_span # => 1..1
node.source_range.line_span(exclude_end: true) # => 1...4
# File 'lib/rubocop/ast/ext/range.rb', line 20
def line_span(exclude_end: false) ::Range.new(first_line, last_line, exclude_end) end