Class: Symbolic::Variable
- Inherits:
-
Object
- Object
- Symbolic::Variable
show all
- Includes:
- Symbolic
- Defined in:
- lib/symbolic/variable.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Symbolic
#*, #**, #+, #+@, #-, #-@, #/, #coerce, #operations
Constructor Details
#initialize(options = {}, &proc) ⇒ Variable
Returns a new instance of Variable.
7
8
9
10
11
|
# File 'lib/symbolic/variable.rb', line 7
def initialize(options={}, &proc)
@name, @value = options.values_at(:name, :value)
@name = @name.to_s if @name
@proc = proc
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4
5
6
|
# File 'lib/symbolic/variable.rb', line 4
def name
@name
end
|
#proc ⇒ Object
Returns the value of attribute proc.
4
5
6
|
# File 'lib/symbolic/variable.rb', line 4
def proc
@proc
end
|
#value ⇒ Object
13
14
15
|
# File 'lib/symbolic/variable.rb', line 13
def value
@value || @proc && @proc.call
end
|
Instance Method Details
#detailed_operations ⇒ Object
29
30
31
|
# File 'lib/symbolic/variable.rb', line 29
def detailed_operations
Hash.new 0
end
|
#to_s ⇒ Object
17
18
19
|
# File 'lib/symbolic/variable.rb', line 17
def to_s
@name || 'unnamed_variable'
end
|
#undefined_variables ⇒ Object
25
26
27
|
# File 'lib/symbolic/variable.rb', line 25
def undefined_variables
value ? [] : variables
end
|
#variables ⇒ Object
21
22
23
|
# File 'lib/symbolic/variable.rb', line 21
def variables
[self]
end
|