Sha256: 44303d92d806d6b5ec0cc24596ab15b61236d22ce3c835356cc3c28f0ac1b650
Contents?: true
Size: 1.2 KB
Versions: 1
Compression:
Stored size: 1.2 KB
Contents
class Rtml::HighLevel::VariableManager attr_accessor :screen def initialize() @vars = HashWithIndifferentAccess.new Rtml::Test::BuiltinVariables::BUILTIN_VARIABLES.each do |name, options| @vars[name] = Rtml::HighLevel::ManagedVariable.new(name) end end def [](variable_name) variable_name = variable_name.to_s unless variable_name.kind_of?(String) if !@vars.key?(variable_name) vardec = screen.document.variable_names.include?(variable_name) raise Rtml::Errors::MissingVariableError, "Could not find a TML variable named #{variable_name.inspect}. "+ "Did you forget to declare it?" unless vardec end @vars[variable_name] ||= Rtml::HighLevel::ManagedVariable.new(variable_name) end def []=(target, other) case other when Rtml::HighLevel::ManagedVariable screen.set self[target].name => "tmlvar:#{other.name}" else screen.set self[target].name => other end end def method_missing(name, *args, &block) if args.empty? && !block_given? self.send(:[], name) elsif name.to_s[-1] == ?= && args.length == 1 && !block_given? self.send(:[]=, name.to_s[0...-1], *args) else super end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rtml-2.0.4 | lib/rtml/high_level/variable_manager.rb |