Class: Unroller::Variables
- Inherits:
-
Object
- Object
- Unroller::Variables
- Defined in:
- lib/unroller.rb
Overview
Helper classes
Instance Method Summary collapse
- #any? ⇒ Boolean
-
#initialize(which, binding) ⇒ Variables
constructor
A new instance of Variables.
- #to_s ⇒ Object
- #verbose_to_s ⇒ Object
Constructor Details
#initialize(which, binding) ⇒ Variables
Returns a new instance of Variables.
81 82 83 84 85 86 |
# File 'lib/unroller.rb', line 81 def initialize(which, binding) @variables = eval("#{which}_variables", binding).map { |variable| value = eval(variable, binding) [variable, value] } end |
Instance Method Details
#any? ⇒ Boolean
101 102 103 |
# File 'lib/unroller.rb', line 101 def any? !@variables.empty? end |
#to_s ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/unroller.rb', line 87 def to_s #@variables.inspect @variables.map do |variable| name, value = *variable "#{name} = #{value.inspect}" end.join('; ').bracket(' (', ')') end |
#verbose_to_s ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/unroller.rb', line 94 def verbose_to_s @variables.map do |variable| name, value = *variable "#{name} = " + value.pp_s.gsub(/^/, ' ') end.join("\n") end |