class TracLang::Bindings

Binding of name to Form represented by the name.

Attributes

bindings[R]

Hash map of names to Forms.

Public Class Methods

new(*bindings) click to toggle source

Creates bindings from list of names and Forms.

# File lib/trac_lang/bindings.rb, line 13
def initialize(*bindings)
  @bindings = Hash[bindings]
end

Public Instance Methods

add(*binding) click to toggle source

Adds a binding to the map of bindings. Will replace a binding with the same name.

# File lib/trac_lang/bindings.rb, line 23
def add(*binding)
  if binding[0].is_a? Array
    @bindings.merge!(Hash[binding])
  else
    @bindings.merge!(Hash[[binding]])
  end
end
clear() click to toggle source

Clears all bindings.

# File lib/trac_lang/bindings.rb, line 18
def clear
  @bindings.clear
end
delete(name) click to toggle source

Unbinds any Form bound to the given name.

# File lib/trac_lang/bindings.rb, line 43
def delete(name)
  @bindings.delete(name)
end
each(&blk) click to toggle source

Passes each binding to the given block.

# File lib/trac_lang/bindings.rb, line 48
def each(&blk)
  @bindings.each(&blk)
end
fetch(name) click to toggle source

Fetches the Form with the given name. Returns nil if no Form has the given name.

# File lib/trac_lang/bindings.rb, line 32
def fetch(name)
  @bindings.fetch(name, nil)
end
fetch_binding(name) click to toggle source

Fetches the binding for the given name, or nil if nothing has the given name.

# File lib/trac_lang/bindings.rb, line 37
def fetch_binding(name)
  f = @bindings.fetch(name, nil)
  return f ? [name, f] : nil
end