Class: Qrpm::ValueNode

Inherits:
Node
  • Object
show all
Defined in:
lib/qrpm/node.rb

Direct Known Subclasses

StandardDirNode

Instance Attribute Summary collapse

Attributes inherited from Node

#expr, #name, #parent, #path

Instance Method Summary collapse

Methods inherited from Node

#class_name, #dot, #inspect, #interpolated?, #traverse

Constructor Details

#initialize(parent, name, expr) ⇒ ValueNode

Returns a new instance of ValueNode.



124
125
126
127
128
# File 'lib/qrpm/node.rb', line 124

def initialize(parent, name, expr)
  expr ||= Fragment::NilFragment.new
  constrain expr, Fragment::Fragment
  super
end

Instance Attribute Details

#valueObject (readonly)

Override Qrpm#value. Initially nil, initialized by #interpolate



122
123
124
# File 'lib/qrpm/node.rb', line 122

def value
  @value
end

Instance Method Details

#dumpObject



139
# File 'lib/qrpm/node.rb', line 139

def dump() puts value ? value : source end

#interpolate(dict) ⇒ Object



133
134
135
136
# File 'lib/qrpm/node.rb', line 133

def interpolate(dict)
  @value ||= expr.interpolate(dict) # Allows StandardDirNode to do its own assignment
  super
end

#signatureObject



138
# File 'lib/qrpm/node.rb', line 138

def signature() "#{class_name}(#{name},#{expr.source})" end

#sourceObject

Source code of expression



119
# File 'lib/qrpm/node.rb', line 119

def source() @expr.source end

#variablesObject

Override Qrpm methods



131
# File 'lib/qrpm/node.rb', line 131

def variables() @variables ||= expr.variables end