A ficticious node representing an idenfitifer like, foo, Bar or something_else.
The parser doesn't create this nodes. Instead, you create them by invoking #id
on some nodes. For example, invoking #id on a StringLiteral returns a MacroId
for the string's content. Similarly, invoking ID on a SymbolLiteral, Call, Var and Path
return MacroIds for the node's content.
This allows you to treat strings, symbols, variables and calls unifomly. For example:
macro getter(name)
def {{name.id}}
@{{name.id}}
end
end
getter unicorns
getter :unicorns
getter "unicorns"
All of the above macro calls work because we invoked #id, and the generated code
looks like this:
def unicorns
@unicorns
end
If we hand't use #id, the generated code would have been this:
def unicorns
@unicorns
end
def :unicorns
@:unicorns
end
def "unicorns"
@"unicorns"
end
The last two definitions are invalid and so will give a compile-time error.
Similar to String#+.
Similar to String#=~.
Similar to String#[].
Similar to String#capitalize.
Similar to String#chars.
Similar to String#chomp.
Similar to String#downcase.
Similar to String#empty?.
Similar to String#ends_with?.
Similar to String#gsub.
Returns self.
Similar to String#length.
Similar to String#lines.
Similar to String#split.
Similar to String#split.
Similar to String#starts_with?.
Similar to String#strip.
Similar to String#tr.
Similar to String#upcase.
Similar to String#+.
Similar to String#=~.
Similar to String#[].
Similar to String#capitalize.
Similar to String#chars.
Similar to String#chomp.
Similar to String#downcase.
Similar to String#empty?.
Similar to String#ends_with?.
Similar to String#gsub.
Returns self.
Similar to String#length.
Similar to String#lines.
Similar to String#split.
Similar to String#split.
Similar to String#starts_with?.
Similar to String#strip.
Similar to String#tr.
Similar to String#upcase.