Sha256: ff51e56415a45486223e19a453c7dc7d986fd529dd54ce9f53c5b11496669223
Contents?: true
Size: 1.15 KB
Versions: 1
Compression:
Stored size: 1.15 KB
Contents
module Tcl module Ruby class Interpreter private def ___array(*arg) send("___array_#{arg[0]}", *arg[1..-1]) rescue ArgumentError => e raise(TclArgumentError, "array #{arg[0]}: #{e.message}") end def ___array_set(name, list) raise(CommandError, "#{name} is not array") unless @variables[name].is_a?(Hash) || !@variables.key?(name) l = parse(list, true).to_h @variables[name] ||= {} @variables[name].merge!(l) end def ___array_unset(name, pattern = nil) return '' unless @variables[name].is_a?(Hash) if pattern @variables[name].delete(pattern) else @variables.delete(name) end '' end def ___array_get(name, pattern = nil) return '' unless @variables[name].is_a?(Hash) if pattern return '' unless @variables[name].key?(pattern) "#{pattern} #{@variables[name][pattern]}" else @variables[name].flatten.join(' ') end end def ___array_exists(name) @variables[name].is_a?(Hash) ? '1' : '0' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tcl-ruby-0.1.1 | lib/tcl/ruby/commands/array.rb |