Class: Ibex::Runtime::CST::GreenTrivia
- Inherits:
-
Object
- Object
- Ibex::Runtime::CST::GreenTrivia
- 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
- #full_width ⇒ Integer readonly
- #hash ⇒ Integer readonly
- #kind ⇒ Integer readonly
- #text ⇒ String readonly
Instance Method Summary collapse
- #==(other) ⇒ Boolean (also: #eql?)
-
#initialize(kind:, text:) ⇒ GreenTrivia
constructor
A new instance of GreenTrivia.
- #to_source ⇒ String
Constructor Details
#initialize(kind:, text:) ⇒ GreenTrivia
Returns a new instance of GreenTrivia.
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_width ⇒ Integer (readonly)
11 12 13 |
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 11 def full_width @full_width end |
#hash ⇒ Integer (readonly)
12 13 14 |
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 12 def hash @hash end |
#kind ⇒ Integer (readonly)
9 10 11 |
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 9 def kind @kind end |
#text ⇒ String (readonly)
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?
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_source ⇒ String
24 |
# File 'lib/ibex/runtime/cst/green/trivia.rb', line 24 def to_source = @text |