Class: Lustr4XUL::GenerationContext

Inherits:
Builder::XmlMarkup
  • Object
show all
Defined in:
lib/lustr-xul/_common.rb

Direct Known Subclasses

XBLGenerationContext, XULGenerationContext

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ GenerationContext

Returns a new instance of GenerationContext.



24
25
26
27
28
29
# File 'lib/lustr-xul/_common.rb', line 24

def initialize(name)
	super()
	@name=name
	@namespaces={'xmlns:xul'=>"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"}
	@script_needed=true
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



22
23
24
# File 'lib/lustr-xul/_common.rb', line 22

def name
  @name
end

Instance Method Details

#build_gadget_ref(gadget) ⇒ Object



35
36
37
# File 'lib/lustr-xul/_common.rb', line 35

def build_gadget_ref(gadget)
	self.xul :box, :class=>gadget.builder.name.to_sym, :id=>gadget.name
end

#descend(widget) ⇒ Object



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/lustr-xul/_common.rb', line 51

def descend(widget)
	if @script_needed
		self.xul :script, 'src'=>'_'+@name+'.js'
		@script_needed=false
	end

	first=true if block_given?

	widget.children.each do |child|
		child.generate(self)
		
		if first
			first=false
			yield
		end
	end
end

#net_attrs(raw = {}) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
# File 'lib/lustr-xul/_common.rb', line 39

def net_attrs(raw={})
	result=raw.reject {|key, value| !value || (value.kind_of?(String) && value.size==0)}
	
	if @namespaces
		result.merge!(@namespaces)
	end
	
	@namespaces=nil

	return result
end

#to_sObject



31
32
33
# File 'lib/lustr-xul/_common.rb', line 31

def to_s
	self.target!
end