Sha256: 4ac96c7db91acea9b4dc31a93f3ab1580407b076f3ac7bb05c96c9aff43c412e
Contents?: true
Size: 1.03 KB
Versions: 7
Compression:
Stored size: 1.03 KB
Contents
class Radiosonde::DSL::Context include Radiosonde::DSL::Validator class << self def eval(dsl, path, opts = {}) self.new(path, opts) { eval(dsl, binding, path) } end end # of class methods attr_reader :result def initialize(path, options = {}, &block) @path = path @options = options @result = OpenStruct.new(:alarms => []) @alarm_names = [] instance_eval(&block) end private def require(file) alarmfile = File.expand_path(File.join(File.dirname(@path), file)) if File.exist?(alarmfile) instance_eval(File.read(alarmfile), alarmfile) elsif File.exist?(alarmfile + '.rb') instance_eval(File.read(alarmfile + '.rb'), alarmfile + '.rb') else Kernel.require(file) end end def alarm(name, &block) _required(:alarm_name, name) _validate("Alarm `#{name}` is already defined") do not @alarm_names.include?(name) end @result.alarms << Radiosonde::DSL::Context::Alarm.new(name, &block).result @alarm_names << name end end
Version data entries
7 entries across 7 versions & 1 rubygems