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.



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

Returns:

  • (Boolean)


101
102
103
# File 'lib/unroller.rb', line 101

def any?
  !@variables.empty?
end

#to_sObject



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_sObject



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