Class: Snuffle::LineOfCode

Inherits:
Object
  • Object
show all
Includes:
Ephemeral::Base, PoroPlus
Defined in:
lib/snuffle/line_of_code.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject

Returns the value of attribute content.



8
9
10
# File 'lib/snuffle/line_of_code.rb', line 8

def content
  @content
end

#line_numberObject

Returns the value of attribute line_number.



8
9
10
# File 'lib/snuffle/line_of_code.rb', line 8

def line_number
  @line_number
end

#rangeObject

Returns the value of attribute range.



8
9
10
# File 'lib/snuffle/line_of_code.rb', line 8

def range
  @range
end

Class Method Details

.containing(locs, start_index, end_index) ⇒ Object



10
11
12
13
14
15
# File 'lib/snuffle/line_of_code.rb', line 10

def self.containing(locs, start_index, end_index)
  locs.inject([]) do |a, loc|
    a << loc if loc.in_range?(start_index) || loc.in_range?(end_index)
    a
  end.compact
end

Instance Method Details

#in_range?(index) ⇒ Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/snuffle/line_of_code.rb', line 17

def in_range?(index)
  self.range.include?(index)
end