Class: Qrpm::Fragment::VariableFragment

Inherits:
Fragment
  • Object
show all
Defined in:
lib/qrpm/fragment.rb

Overview

$NAME or $NAME

Direct Known Subclasses

CommandVariableFragment

Instance Attribute Summary collapse

Attributes inherited from Fragment

#fragments, #source

Instance Method Summary collapse

Methods inherited from Fragment

#is_nil?, parse, #signature, #to_s

Constructor Details

#initialize(source) ⇒ VariableFragment

Returns a new instance of VariableFragment.



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

def initialize(source)
  super
  @name = source.sub(/^\W+(.*?)\W*$/, '\1')
end

Instance Attribute Details

#nameObject (readonly)

Name of the variable excluding ‘$’ and ‘${}’



119
120
121
# File 'lib/qrpm/fragment.rb', line 119

def name
  @name
end

Instance Method Details

#interpolate(dict) ⇒ Object



127
# File 'lib/qrpm/fragment.rb', line 127

def interpolate(dict) dict[name] end

#variablesObject



126
# File 'lib/qrpm/fragment.rb', line 126

def variables() [name] end