Class: Tokn::Token
- Inherits:
-
Object
- Object
- Tokn::Token
- Defined in:
- lib/tokn/tokenizer.rb
Overview
Tokens read by Tokenizer
Instance Attribute Summary collapse
-
#column ⇒ Object
readonly
Returns the value of attribute column.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#lineNumber ⇒ Object
readonly
Returns the value of attribute lineNumber.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(id, text, lineNumber, column) ⇒ Token
constructor
A new instance of Token.
-
#inspect ⇒ Object
Construct description of token location within text.
- #unknown? ⇒ Boolean
Constructor Details
#initialize(id, text, lineNumber, column) ⇒ Token
Returns a new instance of Token.
252 253 254 255 256 257 |
# File 'lib/tokn/tokenizer.rb', line 252 def initialize(id, text, lineNumber, column) @id = id @text = text @lineNumber = lineNumber @column = column end |
Instance Attribute Details
#column ⇒ Object (readonly)
Returns the value of attribute column.
250 251 252 |
# File 'lib/tokn/tokenizer.rb', line 250 def column @column end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
250 251 252 |
# File 'lib/tokn/tokenizer.rb', line 250 def id @id end |
#lineNumber ⇒ Object (readonly)
Returns the value of attribute lineNumber.
250 251 252 |
# File 'lib/tokn/tokenizer.rb', line 250 def lineNumber @lineNumber end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
250 251 252 |
# File 'lib/tokn/tokenizer.rb', line 250 def text @text end |
Instance Method Details
#inspect ⇒ Object
Construct description of token location within text
265 266 267 268 269 270 271 |
# File 'lib/tokn/tokenizer.rb', line 265 def inspect s = "(line "+lineNumber.to_s+", col "+column.to_s+")" if !unknown? s = s.ljust(17) + " : " + text end s end |
#unknown? ⇒ Boolean
259 260 261 |
# File 'lib/tokn/tokenizer.rb', line 259 def unknown? id == ToknInternal::UNKNOWN_TOKEN end |