Class: Qrpm::Fragment::VariableFragment
- Defined in:
- lib/qrpm/fragment.rb
Overview
$NAME or $NAME
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Name of the variable excluding ‘$’ and ‘${}’.
Attributes inherited from Fragment
Instance Method Summary collapse
-
#initialize(source) ⇒ VariableFragment
constructor
A new instance of VariableFragment.
- #interpolate(dict) ⇒ Object
- #variables ⇒ Object
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
#name ⇒ Object (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 |
#variables ⇒ Object
126 |
# File 'lib/qrpm/fragment.rb', line 126 def variables() [name] end |