Class: Bricolage::Variable

Inherits:
Object
  • Object
show all
Defined in:
lib/bricolage/variables.rb

Direct Known Subclasses

ResolvedVariable

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



195
196
197
# File 'lib/bricolage/variables.rb', line 195

def name
  @name
end

#valueObject (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.expand_string(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

#inspectObject



202
203
204
# File 'lib/bricolage/variables.rb', line 202

def inspect
  "\#<#{self.class} #{@name}=#{@value.inspect}>"
end

#resolved?Boolean

Returns:

  • (Boolean)


198
199
200
# File 'lib/bricolage/variables.rb', line 198

def resolved?
  false
end