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