screenomat/lib/screenie/dsl/builder.rb
John Bintz 234a6734b3 stuff
2010-12-09 16:20:21 -05:00

36 lines
624 B
Ruby

require 'screenie/dsl/session'
module Screenie
module DSL
class Builder
attr_reader :sessions
def initialize(code = '', &block)
@sessions = []
if !code.empty?
instance_eval(code)
else
instance_eval(&block)
end
end
def session(name = nil, &block)
name ||= "screenie-#{Time.now.to_i}"
session = Session.new(name.to_sym, &block)
@sessions << session
end
def first
@sessions.first
end
def [](key)
@sessions.find { |session| session.name == key }
end
end
end
end