Class: LibRubyParser::SourceLine

Inherits:
Object
  • Object
show all
Defined in:
lib/lib-ruby-parser.rb

Overview

Representation of a source line in a source file

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ SourceLine

Returns a new instance of SourceLine.

Parameters:

  • options (Hash)

Options Hash (**options):

  • :start (Integer)
  • :end (Integer)
  • :ends_with_eof (true, false)


215
216
217
218
219
# File 'lib/lib-ruby-parser.rb', line 215

def initialize(**options)
  @start = options[:start]
  @end = options[:end]
  @ends_with_eof = options[:ends_with_eof]
end

Instance Attribute Details

#endInteger

End of the line (in bytes)

Returns:

  • (Integer)


204
205
206
# File 'lib/lib-ruby-parser.rb', line 204

def end
  @end
end

#ends_with_eoftrue, false

+true+ if line ends with EOF char (which is true for the last line in the file)

Returns:

  • (true, false)


209
210
211
# File 'lib/lib-ruby-parser.rb', line 209

def ends_with_eof
  @ends_with_eof
end

#startInteger

Start of the line (in bytes)

Returns:

  • (Integer)


199
200
201
# File 'lib/lib-ruby-parser.rb', line 199

def start
  @start
end

Instance Method Details

#==(other) ⇒ Object

Default +==+ comparison



222
223
224
225
226
# File 'lib/lib-ruby-parser.rb', line 222

def ==(other)
  start == other.start &&
    self.end == other.end &&
    ends_with_eof == other.ends_with_eof
end