Module: Lustr::WidgetBase

Included in:
Gadget, TemplatedWidget, XmlBasedWidget
Defined in:
lib/lustr/widget.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#eval_contextObject

Returns the value of attribute eval_context.



22
23
24
# File 'lib/lustr/widget.rb', line 22

def eval_context
  @eval_context
end

#gadgetObject

Returns the value of attribute gadget.



22
23
24
# File 'lib/lustr/widget.rb', line 22

def gadget
  @gadget
end

#labelObject

Returns the value of attribute label.



22
23
24
# File 'lib/lustr/widget.rb', line 22

def label
  @label
end

#nameObject

Returns the value of attribute name.



22
23
24
# File 'lib/lustr/widget.rb', line 22

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



23
24
25
# File 'lib/lustr/widget.rb', line 23

def options
  @options
end

#parentObject

Returns the value of attribute parent.



22
23
24
# File 'lib/lustr/widget.rb', line 22

def parent
  @parent
end

Instance Method Details

#<<(child) ⇒ Object



30
31
32
# File 'lib/lustr/widget.rb', line 30

def <<(child)
	_add(child)
end

#_add(child) ⇒ Object



34
35
36
37
# File 'lib/lustr/widget.rb', line 34

def _add(child)
	children << child
	child.parent=self
end

#childrenObject



25
26
27
28
# File 'lib/lustr/widget.rb', line 25

def children
	@children||=[]
	@children
end

#controller=(thing) ⇒ Object



55
56
57
# File 'lib/lustr/widget.rb', line 55

def controller=(thing)
	gadget.controller=thing
end

#init_options(options) ⇒ Object



47
48
49
# File 'lib/lustr/widget.rb', line 47

def init_options(options)
	@options=options
end

#option(name) ⇒ Object



51
52
53
# File 'lib/lustr/widget.rb', line 51

def option(name)
	return options[name]
end

#raise_event(expr, event = nil) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/lustr/widget.rb', line 59

def raise_event(expr, event=nil)
	if expr
		if expr.kind_of?(Proc)
			expr.call(event, gadget)
		elsif expr.kind_of?(Symbol)
			gadget.controller.send(expr, event) if gadget.controller
		else
			gadget.controller.instance_eval(expr) if gadget.controller
		end
	end
end

#resolveObject



39
40
41
# File 'lib/lustr/widget.rb', line 39

def resolve
	return self
end

#resolve_parentObject



43
44
45
# File 'lib/lustr/widget.rb', line 43

def resolve_parent
	return self
end

#to_sObject



71
72
73
74
# File 'lib/lustr/widget.rb', line 71

def to_s
	return label if label
	return super
end