Class: Token::Resolver::Node::Text
- Inherits:
-
Object
- Object
- Token::Resolver::Node::Text
- Defined in:
- lib/token/resolver/node/text.rb
Overview
Represents plain text content (not a token).
Text nodes hold the literal string content between (or outside of) tokens.
They are frozen after creation.
Instance Attribute Summary collapse
-
#content ⇒ String
readonly
The text content.
Instance Method Summary collapse
-
#eql?(other) ⇒ Boolean
(also: #==)
Equality based on content.
-
#hash ⇒ Integer
-
#initialize(content) ⇒ Text
constructor
A new instance of Text.
-
#inspect ⇒ String
-
#text? ⇒ Boolean
-
#to_s ⇒ String
The text content.
-
#token? ⇒ Boolean
Constructor Details
#initialize(content) ⇒ Text
Returns a new instance of Text.
21 22 23 24 |
# File 'lib/token/resolver/node/text.rb', line 21 def initialize(content) @content = content.frozen? ? content : content.dup.freeze freeze end |
Instance Attribute Details
#content ⇒ String (readonly)
Returns The text content.
18 19 20 |
# File 'lib/token/resolver/node/text.rb', line 18 def content @content end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
Equality based on content.
45 46 47 |
# File 'lib/token/resolver/node/text.rb', line 45 def eql?(other) other.is_a?(Text) && content == other.content end |
#hash ⇒ Integer
52 53 54 |
# File 'lib/token/resolver/node/text.rb', line 52 def hash [self.class, content].hash end |
#inspect ⇒ String
57 58 59 |
# File 'lib/token/resolver/node/text.rb', line 57 def inspect "#<#{self.class} #{content.inspect}>" end |
#text? ⇒ Boolean
37 38 39 |
# File 'lib/token/resolver/node/text.rb', line 37 def text? true end |
#to_s ⇒ String
Returns The text content.
27 28 29 |
# File 'lib/token/resolver/node/text.rb', line 27 def to_s @content end |
#token? ⇒ Boolean
32 33 34 |
# File 'lib/token/resolver/node/text.rb', line 32 def token? false end |