Class: DSL::Var::Table
- Inherits:
-
Hash
- Object
- Hash
- DSL::Var::Table
- Defined in:
- tools/dsl.rb
Instance Method Summary collapse
- #add(&block) ⇒ Object
- #defined?(name) ⇒ Boolean
- #fetch(arg, &block) ⇒ Object
-
#initialize(&block) ⇒ Table
constructor
A new instance of Table.
- #new_var ⇒ Object
Constructor Details
#initialize(&block) ⇒ Table
Returns a new instance of Table.
48 49 50 51 52 |
# File 'tools/dsl.rb', line 48 def initialize(&block) super() {|tbl, arg| tbl.fetch(arg, &block) } end |
Instance Method Details
#add(&block) ⇒ Object
60 61 62 63 |
# File 'tools/dsl.rb', line 60 def add(&block) v = new_var self[v] = Var.new(self, v, &block) end |
#defined?(name) ⇒ Boolean
65 66 67 68 |
# File 'tools/dsl.rb', line 65 def defined?(name) name = name.to_s any? {|_, v| v.var == name} end |
#fetch(arg, &block) ⇒ Object
54 55 56 57 58 |
# File 'tools/dsl.rb', line 54 def fetch(arg, &block) super { self[arg] = Var.new(self, arg, &block) } end |
#new_var ⇒ Object
70 71 72 |
# File 'tools/dsl.rb', line 70 def new_var "v#{size+1}" end |