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.



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

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)


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

def any?
  !@variables.empty?
end

#to_sObject



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

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



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

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