Class: Unroller::Variables

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

Overview


Helper classes

Instance Method Summary collapse

Constructor Details

#initialize(which, binding) ⇒ Variables

Returns a new instance of Variables.



123
124
125
126
127
128
# File 'lib/unroller.rb', line 123

def initialize(which, binding)
  @variables = eval("#{which}_variables", binding).map { |variable|
    value = eval(variable, binding)
    [variable, value]
  }
end

Instance Method Details

#any?Boolean

Returns:

  • (Boolean)


144
145
146
# File 'lib/unroller.rb', line 144

def any?
  !@variables.empty?
end

#to_sObject



129
130
131
132
133
134
135
136
# File 'lib/unroller.rb', line 129

def to_s
  #@variables.inspect
  ret = @variables.map do |variable|
    name, value = *variable
    "#{name} = #{value.inspect}"
  end.join('; ').bracket('   (', ')')
  ret[0..70] + '...'  # Maybe truncating it could be optional in the future, but for now it's just too cluttered
end

#verbose_to_sObject



137
138
139
140
141
142
143
# File 'lib/unroller.rb', line 137

def verbose_to_s
  @variables.map do |variable|
    name, value = *variable
    "#{name} = " +
      value.pp_s.gsub(/^/, '  ')
  end.join("\n")
end