Class: LexerPosition
Instance Attribute Summary collapse
-
#char_position ⇒ Object
readonly
Returns the value of attribute char_position.
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#row ⇒ Object
readonly
Returns the value of attribute row.
Instance Method Summary collapse
- #+(aString) ⇒ Object
-
#initialize(row = 0, column = 0, char_position = 0) ⇒ LexerPosition
constructor
A new instance of LexerPosition.
- #inspect ⇒ Object
Constructor Details
#initialize(row = 0, column = 0, char_position = 0) ⇒ LexerPosition
Returns a new instance of LexerPosition.
230 231 232 |
# File 'lib/rpdf2txt-rockit/token.rb', line 230 def initialize(row = 0, column = 0, char_position = 0) @row, @column, @char_position = row, column, char_position end |
Instance Attribute Details
#char_position ⇒ Object (readonly)
Returns the value of attribute char_position.
228 229 230 |
# File 'lib/rpdf2txt-rockit/token.rb', line 228 def char_position @char_position end |
#column ⇒ Object (readonly)
Returns the value of attribute column.
228 229 230 |
# File 'lib/rpdf2txt-rockit/token.rb', line 228 def column @column end |
#row ⇒ Object (readonly)
Returns the value of attribute row.
228 229 230 |
# File 'lib/rpdf2txt-rockit/token.rb', line 228 def row @row end |
Instance Method Details
#+(aString) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
# File 'lib/rpdf2txt-rockit/token.rb', line 234 def +(aString) char_position = @char_position + aString.length num_newlines = aString.count "\r\n" row = @row if num_newlines == 0 column = @column + aString.length else row += num_newlines begin column = aString.split("\n").last.split("\r").last.length rescue NameError column = 0 end end LexerPosition.new(row, column, char_position) end |
#inspect ⇒ Object
251 252 253 |
# File 'lib/rpdf2txt-rockit/token.rb', line 251 def inspect "(row=#{row},column=#{@column})" end |