Class: Bricolage::Variable
- Inherits:
-
Object
- Object
- Bricolage::Variable
- Defined in:
- lib/bricolage/variables.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
-
.expand_string(str) ⇒ Object
generic variable extractor.
- .list(str) ⇒ Object
Instance Method Summary collapse
-
#initialize(name, value) ⇒ Variable
constructor
A new instance of Variable.
- #inspect ⇒ Object
- #resolved? ⇒ Boolean
Constructor Details
#initialize(name, value) ⇒ Variable
Returns a new instance of Variable.
190 191 192 193 |
# File 'lib/bricolage/variables.rb', line 190 def initialize(name, value) @name = name @value = value end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
195 196 197 |
# File 'lib/bricolage/variables.rb', line 195 def name @name end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
196 197 198 |
# File 'lib/bricolage/variables.rb', line 196 def value @value end |
Class Method Details
.expand_string(str) ⇒ Object
generic variable extractor
182 183 184 |
# File 'lib/bricolage/variables.rb', line 182 def Variable.(str) str.gsub(/\$(\w+)|\$\{(\w+)\}/) { yield ($1 || $2) } end |
.list(str) ⇒ Object
186 187 188 |
# File 'lib/bricolage/variables.rb', line 186 def Variable.list(str) str.scan(/\$(\w+)|\$\{(\w+)\}/).flatten.compact.uniq end |
Instance Method Details
#inspect ⇒ Object
202 203 204 |
# File 'lib/bricolage/variables.rb', line 202 def inspect "\#<#{self.class} #{@name}=#{@value.inspect}>" end |
#resolved? ⇒ Boolean
198 199 200 |
# File 'lib/bricolage/variables.rb', line 198 def resolved? false end |