Class: Maccro::DSL::Node
- Inherits:
-
Object
- Object
- Maccro::DSL::Node
- Includes:
- ASTNodeWrapper
- Defined in:
- lib/maccro/dsl/node.rb
Direct Known Subclasses
AndAssignment, AndExp, AnyNode, Array, ArrayAssignmentWithOperator, Assignment, AttributeAssignment, AttributeAssignmentWithOperator, BackRefVariable, CallExp, CaseExp, ClassVariable, ClassVariableAssignment, Colon2Exp, Colon3Exp, Constant, ConstantDeclaration, ConstantDeclarationWithOperator, DRegexp, DString, DSymbol, DXString, DefineMethod, DefineSingletonMethod, DefinedExp, Dot2Exp, Dot3Exp, DynamicVariableAssignmentCurrentScope, DynamicVariableAssignmentOutOfScope, Expression, FString, FalseValue, Flip2Exp, Flip3Exp, FunctionCallExp, GlobalVariable, GlobalVariableAssignment, Hash, IfExp, InstanceVariable, InstanceVariableAssignment, Lambda, Literal, LocalVariable, LocalVariableAssignment, MatchExp, MultiAssignment, NilValue, NthRefVariable, Number, OperatorCallExp, OrAssignment, OrExp, RegexpCompiledOnce, RegularExpression, SafeCallExp, Self, SpecialVariable, String, SuperExp, Symbol, TrueValue, UnlessExp, VCallExp, Value, Variable, XString, YieldExp
Instance Attribute Summary collapse
-
#first_column ⇒ Object
readonly
Returns the value of attribute first_column.
-
#first_lineno ⇒ Object
readonly
Returns the value of attribute first_lineno.
-
#last_column ⇒ Object
readonly
Returns the value of attribute last_column.
-
#last_lineno ⇒ Object
readonly
Returns the value of attribute last_lineno.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #capture(ast, placeholders) ⇒ Object
- #children ⇒ Object
-
#initialize(name, code_range) ⇒ Node
constructor
A new instance of Node.
- #match?(node) ⇒ Boolean
- #to_code_range ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(name, code_range) ⇒ Node
Returns a new instance of Node.
42 43 44 45 46 47 48 49 |
# File 'lib/maccro/dsl/node.rb', line 42 def initialize(name, code_range) @name = name @code_range = code_range @first_lineno = code_range.first_lineno @first_column = code_range.first_column @last_lineno = code_range.last_lineno @last_column = code_range.last_column end |
Instance Attribute Details
#first_column ⇒ Object (readonly)
Returns the value of attribute first_column.
38 39 40 |
# File 'lib/maccro/dsl/node.rb', line 38 def first_column @first_column end |
#first_lineno ⇒ Object (readonly)
Returns the value of attribute first_lineno.
38 39 40 |
# File 'lib/maccro/dsl/node.rb', line 38 def first_lineno @first_lineno end |
#last_column ⇒ Object (readonly)
Returns the value of attribute last_column.
38 39 40 |
# File 'lib/maccro/dsl/node.rb', line 38 def last_column @last_column end |
#last_lineno ⇒ Object (readonly)
Returns the value of attribute last_lineno.
38 39 40 |
# File 'lib/maccro/dsl/node.rb', line 38 def last_lineno @last_lineno end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
38 39 40 |
# File 'lib/maccro/dsl/node.rb', line 38 def name @name end |
Instance Method Details
#capture(ast, placeholders) ⇒ Object
74 75 76 |
# File 'lib/maccro/dsl/node.rb', line 74 def capture(ast, placeholders) placeholders[@name] = ast.to_code_range end |
#children ⇒ Object
59 60 61 |
# File 'lib/maccro/dsl/node.rb', line 59 def children [] end |
#match?(node) ⇒ Boolean
63 64 65 66 67 68 69 70 71 72 |
# File 'lib/maccro/dsl/node.rb', line 63 def match?(node) # literals are not Node in any cases return false unless node.respond_to?(:type) if self.class.respond_to?(:match?) self.class.match?(node) else super end end |
#to_code_range ⇒ Object
51 52 53 |
# File 'lib/maccro/dsl/node.rb', line 51 def to_code_range @code_range end |
#type ⇒ Object
55 56 57 |
# File 'lib/maccro/dsl/node.rb', line 55 def type :MACCRO_NODE end |