Module: Yoda::AST::CommentBlock::RangeCalculation Abstract

Included in:
BasePart
Defined in:
lib/yoda/ast/comment_block/range_calculation.rb

Overview

This module is abstract.

Instance Method Summary collapse

Instance Method Details

#begin_indexInteger

This method is abstract.

Returns:

  • (Integer)


12
13
14
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 12

def begin_index
  fail NotImplementedError
end

#begin_locationParsing::Location?

Returns:



23
24
25
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 23

def begin_location
  @begin_location ||= comment_block.location_from_index(begin_index)
end

#comment_blockCommentBlock

This method is abstract.

Returns:



# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 6

#end_indexInteger

This method is abstract.

Returns:

  • (Integer)


18
19
20
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 18

def end_index
  fail NotImplementedError
end

#end_locationParsing::Location?

Returns:



28
29
30
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 28

def end_location
  @end_location ||= comment_block.location_from_index(end_index)
end

#include?(location) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)


52
53
54
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 52

def include?(location)
  range&.include?(location)
end

#rangeParsing::Range?

Returns:



33
34
35
36
37
38
39
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 33

def range
  if begin_location && end_location
    Parsing::Range.new(begin_location, end_location)
  else
    nil
  end
end

#textString?

Returns:

  • (String, nil)


42
43
44
45
46
47
48
# File 'lib/yoda/ast/comment_block/range_calculation.rb', line 42

def text
  if begin_location && end_location
    comment_block.text.slice(Range.new(begin_index, end_index))
  else
    nil
  end
end