Class: Ibex::Runtime::CST::GreenTrivia

Inherits:
Object
  • Object
show all
Defined in:
lib/json5/generated_parser.rb

Overview

Immutable source text ignored by the grammar but owned by a token.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, text:) ⇒ GreenTrivia

Returns a new instance of GreenTrivia.

RBS:

  • (kind: Integer, text: String) -> void



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_widthObject (readonly)

Signature:

  • Integer



289
290
291
# File 'lib/json5/generated_parser.rb', line 289

def full_width
  @full_width
end

#hashObject (readonly)

Signature:

  • Integer



290
291
292
# File 'lib/json5/generated_parser.rb', line 290

def hash
  @hash
end

#kindObject (readonly)

Signature:

  • Integer



287
288
289
# File 'lib/json5/generated_parser.rb', line 287

def kind
  @kind
end

#textObject (readonly)

Signature:

  • String



288
289
290
# File 'lib/json5/generated_parser.rb', line 288

def text
  @text
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?

RBS:

  • (Object? other) -> bool



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_sourceObject

RBS:

  • () -> String



302
# File 'lib/json5/generated_parser.rb', line 302

def to_source = @text