Skip to content

Instantly share code, notes, and snippets.

@burke burke/ohno.rb
Created Sep 24, 2019

Embed
What would you like to do?
require('yaml')
module Ohno
def self.replace_index(welp, index)
case welp
when String
welp == "$index" ? index : welp.gsub(/\$index/, index.to_s)
else
welp
end
end
end
class Loop
def self.allocate
k = Class.new(Array)
k.send(:define_method, :init_with) do |coder|
(coder.map['from']..coder.map['to']).each do |index|
push(Ohno.replace_index(coder.map['do'], index))
end
end
k.new
end
end
puts YAML.load(DATA.read).inspect
__END__
--- !ruby/object:Loop
from: 0
to: 3
do: $index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.