Class: MiniRuby::AST::AttributeAccessExpressionNode
- Inherits:
-
ExpressionNode
- Object
- Node
- ExpressionNode
- MiniRuby::AST::AttributeAccessExpressionNode
- Defined in:
- lib/miniruby/ast.rb
Overview
Represents an attribute access expression like ‘foo.bar`
Instance Attribute Summary collapse
-
#field ⇒ Object
readonly
: IdentifierNode.
-
#receiver ⇒ Object
readonly
: ExpressionNode.
Attributes inherited from Node
Instance Method Summary collapse
-
#==(other) ⇒ Object
: (Object other) -> bool.
-
#initialize(receiver:, field:, span: Span::ZERO) ⇒ AttributeAccessExpressionNode
constructor
: (receiver: ExpressionNode, field: IdentifierNode, ?span: Span) -> void.
-
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String.
-
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String.
Constructor Details
#initialize(receiver:, field:, span: Span::ZERO) ⇒ AttributeAccessExpressionNode
: (receiver: ExpressionNode, field: IdentifierNode, ?span: Span) -> void
269 270 271 272 273 |
# File 'lib/miniruby/ast.rb', line 269 def initialize(receiver:, field:, span: Span::ZERO) @span = span @receiver = receiver @field = field end |
Instance Attribute Details
#field ⇒ Object (readonly)
: IdentifierNode
266 267 268 |
# File 'lib/miniruby/ast.rb', line 266 def field @field end |
#receiver ⇒ Object (readonly)
: ExpressionNode
263 264 265 |
# File 'lib/miniruby/ast.rb', line 263 def receiver @receiver end |
Instance Method Details
#==(other) ⇒ Object
: (Object other) -> bool
276 277 278 279 280 281 |
# File 'lib/miniruby/ast.rb', line 276 def ==(other) return false unless other.is_a?(AttributeAccessExpressionNode) @receiver == other.receiver && @field == other.field end |
#inspect(indent = 0) ⇒ Object
: (?Integer indent) -> String
291 292 293 294 295 296 297 298 299 300 |
# File 'lib/miniruby/ast.rb', line 291 def inspect(indent = 0) buff = String.new buff << "#{INDENT_UNIT * indent}(attr" buff << "\n" << @receiver.inspect(indent + 1) buff << "\n" << @field.inspect(indent + 1) buff << ')' buff end |
#to_s(indent = 0) ⇒ Object
: (?Integer indent) -> String
285 286 287 |
# File 'lib/miniruby/ast.rb', line 285 def to_s(indent = 0) "#{INDENT_UNIT * indent}#{@receiver}.#{@field}" end |