Class: Ibex::Runtime::CST::GreenTrivia
- Inherits:
-
Object
- Object
- Ibex::Runtime::CST::GreenTrivia
- Defined in:
- lib/json5/generated_parser.rb
Overview
Immutable source text ignored by the grammar but owned by a token.
Instance Attribute Summary collapse
- #full_width ⇒ Object readonly
- #hash ⇒ Object readonly
- #kind ⇒ Object readonly
- #text ⇒ Object readonly
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(kind:, text:) ⇒ GreenTrivia
constructor
A new instance of GreenTrivia.
- #to_source ⇒ Object
Constructor Details
#initialize(kind:, text:) ⇒ GreenTrivia
Returns a new instance of GreenTrivia.
293 294 295 296 297 298 299 |
# File 'lib/json5/generated_parser.rb', line 293 def initialize(kind:, text:) @kind = kind @text = text.b.freeze @full_width = @text.bytesize @hash = [@kind, @text].hash freeze end |
Instance Attribute Details
#full_width ⇒ Object (readonly)
289 290 291 |
# File 'lib/json5/generated_parser.rb', line 289 def full_width @full_width end |
#hash ⇒ Object (readonly)
290 291 292 |
# File 'lib/json5/generated_parser.rb', line 290 def hash @hash end |
#kind ⇒ Object (readonly)
287 288 289 |
# File 'lib/json5/generated_parser.rb', line 287 def kind @kind end |
#text ⇒ Object (readonly)
288 289 290 |
# File 'lib/json5/generated_parser.rb', line 288 def text @text end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
305 306 307 |
# File 'lib/json5/generated_parser.rb', line 305 def ==(other) other.is_a?(GreenTrivia) && @kind == other.kind && @text == other.text end |
#to_source ⇒ Object
302 |
# File 'lib/json5/generated_parser.rb', line 302 def to_source = @text |