Class: Wrapper
- Inherits:
-
Object
- Object
- Wrapper
- Defined in:
- lib/rearview/templates/monitor.rb
Instance Method Summary collapse
- #create_timeseries(ts) ⇒ Object
-
#secure_eval(namespace) ⇒ Object
Binding needs to be relative to the class, NOT top level.
-
#variable_by_offset(index) ⇒ Object
Return a variable name (e.g. a,b,c) from an ordinal.
Instance Method Details
#create_timeseries(ts) ⇒ Object
129 130 131 132 133 134 135 136 137 138 |
# File 'lib/rearview/templates/monitor.rb', line 129 def create_timeseries(ts) ns = {} ts = ts.to_a.map { |t| TimeSeries.new(t) } vars = (0...ts.length).map do |i| varname = variable_by_offset(i) ns["@#{varname}"] = ts[i] end ns["@timeseries"] = ts ns end |
#secure_eval(namespace) ⇒ Object
Binding needs to be relative to the class, NOT top level
152 153 154 155 156 157 |
# File 'lib/rearview/templates/monitor.rb', line 152 def secure_eval(namespace) scoped = Scoped.new(%{timeout}) ts = create_timeseries(namespace.to_hash.delete "@timeseries") ns = namespace.to_hash.merge(ts) puts scoped.scoped_eval(ns) end |
#variable_by_offset(index) ⇒ Object
Return a variable name (e.g. a,b,c) from an ordinal
143 144 145 146 147 148 |
# File 'lib/rearview/templates/monitor.rb', line 143 def variable_by_offset(index) offset = 'a'.ord dv = index.divmod(26) ext = dv[0] > 0 ? dv[1].to_s : "" (offset + dv[1]).chr + ext end |