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

Inherits:
Object
  • Object
show all
Defined in:
lib/ibex/runtime/cst/green/trivia.rb,
sig/ibex/runtime/cst/green/trivia.rbs

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

Parameters:

  • kind: (Integer)
  • text: (String)


15
16
17
18
19
20
21
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 15

def initialize(kind:, text:)
  @kind = kind
  @text = text.b.freeze
  @full_width = @text.bytesize
  @hash = [@kind, @text].hash
  freeze
end

Instance Attribute Details

#full_widthInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


11
12
13
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 11

def full_width
  @full_width
end

#hashInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


12
13
14
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 12

def hash
  @hash
end

#kindInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


9
10
11
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 9

def kind
  @kind
end

#textString (readonly)

Signature:

  • String

Returns:

  • (String)


10
11
12
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 10

def text
  @text
end

Instance Method Details

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

RBS:

  • (untyped other) -> bool

Parameters:

  • other (Object)

Returns:

  • (Boolean)


27
28
29
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 27

def ==(other)
  other.is_a?(GreenTrivia) && @kind == other.kind && @text == other.text
end

#to_sourceString

RBS:

  • () -> String

Returns:

  • (String)


24
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 24

def to_source = @text