Class: MiniRuby::AST::StringLiteralNode
- Inherits:
-
ExpressionNode
- Object
- Node
- ExpressionNode
- MiniRuby::AST::StringLiteralNode
- Defined in:
- lib/miniruby/ast.rb
Overview
Represents a string literal eg. ‘“foo”`
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
: String.
Attributes inherited from Node
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(value:, span: Span::ZERO) ⇒ StringLiteralNode
constructor
: (value: String, ?span: Span) -> void.
-
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String.
-
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String.
Constructor Details
#initialize(value:, span: Span::ZERO) ⇒ StringLiteralNode
: (value: String, ?span: Span) -> void
918 919 920 921 |
# File 'lib/miniruby/ast.rb', line 918 def initialize(value:, span: Span::ZERO) @span = span @value = value end |
Instance Attribute Details
#value ⇒ Object (readonly)
: String
915 916 917 |
# File 'lib/miniruby/ast.rb', line 915 def value @value end |
Instance Method Details
#==(other) ⇒ Object
: (Object other) -> bool
924 925 926 927 928 |
# File 'lib/miniruby/ast.rb', line 924 def ==(other) return false unless other.is_a?(StringLiteralNode) @value == other.value end |
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String
938 939 940 |
# File 'lib/miniruby/ast.rb', line 938 def inspect(indent = 0) "#{INDENT_UNIT * indent}#{value.inspect}" end |
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String
932 933 934 |
# File 'lib/miniruby/ast.rb', line 932 def to_s(indent = 0) "#{INDENT_UNIT * indent}#{value.inspect}" end |