Class: LL::SourceLine
- Inherits:
-
Object
- Object
- LL::SourceLine
- 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
- DEFAULT_FILE =
'(ruby)'
Instance Attribute Summary (collapse)
-
- (Object) column
readonly
Returns the value of attribute column.
-
- (Object) data
readonly
Returns the value of attribute data.
-
- (Object) file
readonly
Returns the value of attribute file.
-
- (Object) line
readonly
Returns the value of attribute line.
Instance Method Summary (collapse)
-
- (TrueClass|FalseClass) ==(other)
-
- (SourceLine) initialize(data, line = 1, column = 1, file = DEFAULT_FILE)
constructor
A new instance of SourceLine.
-
- (String) source
Constructor Details
- (SourceLine) initialize(data, line = 1, column = 1, file = DEFAULT_FILE)
Returns a new instance of 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
- (Object) column (readonly)
Returns the value of attribute column
7 8 9 |
# File 'lib/ll/source_line.rb', line 7 def column @column end |
- (Object) data (readonly)
Returns the value of attribute data
7 8 9 |
# File 'lib/ll/source_line.rb', line 7 def data @data end |
- (Object) file (readonly)
Returns the value of attribute file
7 8 9 |
# File 'lib/ll/source_line.rb', line 7 def file @file end |
- (Object) line (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
- (TrueClass|FalseClass) ==(other)
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 |
- (String) source
30 31 32 |
# File 'lib/ll/source_line.rb', line 30 def source return data.lines.to_a[line - 1].chomp end |