Class: LL::SourceLine

Inherits:
Object
  • Object
show all
Defined in:
lib/ll/source_line.rb

Overview

Class containing data of a lexer token's source line source as the raw data, column, line number, etc.

Constant Summary collapse

DEFAULT_FILE =
'(ruby)'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, line = 1, column = 1, file = DEFAULT_FILE) ⇒ SourceLine



20
21
22
23
24
25
# File 'lib/ll/source_line.rb', line 20

def initialize(data, line = 1, column = 1, file = DEFAULT_FILE)
  @file   = file
  @data   = data
  @line   = line
  @column = column
end

Instance Attribute Details

#columnObject (readonly)

Returns the value of attribute column.



7
8
9
# File 'lib/ll/source_line.rb', line 7

def column
  @column
end

#dataObject (readonly)

Returns the value of attribute data.



7
8
9
# File 'lib/ll/source_line.rb', line 7

def data
  @data
end

#fileObject (readonly)

Returns the value of attribute file.



7
8
9
# File 'lib/ll/source_line.rb', line 7

def file
  @file
end

#lineObject (readonly)

Returns the value of attribute line.



7
8
9
# File 'lib/ll/source_line.rb', line 7

def line
  @line
end

Instance Method Details

#==(other) ⇒ TrueClass|FalseClass



37
38
39
40
41
42
43
44
# File 'lib/ll/source_line.rb', line 37

def ==(other)
  return false unless other.class == self.class

  return file == other.file &&
    data == other.data &&
    line == other.line &&
    column == other.column
end

#sourceString



30
31
32
# File 'lib/ll/source_line.rb', line 30

def source
  return data.lines.to_a[line - 1].chomp
end