Module: Cheri::Builder::Frame

Included in:
AWT::AWTFrame, Builder
Defined in:
lib/cheri/builder/base.rb

Overview

Frame provides default implementations of the methods required by objects that will be pushed onto the Cheri::Builder::Context stack. Note that concrete builders will need to override some of these methods, such as #mod, #parent? and #child?.

Frame is provided as a convenience; its use is not required.

If used, Frame should normally be included before other Cheri::Builder convenience modules (such as Content or Attributes). Classes/modules that include it should be sure to call super from their initialize methods, if any.

Instance Method Summary collapse

Instance Method Details

#any?Boolean

Override to return true if object wants the opportunity to connect to any object created in the hierarchy below it. Normally used by non-structural components (Swing’s ButtonGroup, for example). Adds build overhead, so use sparingly.

Returns:

  • (Boolean)


92
93
94
# File 'lib/cheri/builder/base.rb', line 92

def any?
  false
end

#blockObject

Returns @blk, the block passed to this frame, if any.



53
54
55
# File 'lib/cheri/builder/base.rb', line 53

def block
  @blk
end

#child?Boolean

Override to return true if object can be a child of another object. Default: false

Returns:

  • (Boolean)


85
86
87
# File 'lib/cheri/builder/base.rb', line 85

def child?
  false
end

#ctxObject Also known as: context

Returns @ctx, the Context instance to which this frame belongs.



47
48
49
# File 'lib/cheri/builder/base.rb', line 47

def ctx
  @ctx  
end

#initialize(ctx, *args, &blk) ⇒ Object

Stores the context and block (if any) in @ctx and @blk.



40
41
42
43
44
# File 'lib/cheri/builder/base.rb', line 40

def initialize(ctx,*args,&blk) #:doc:
  @ctx = ctx
  @blk = blk if blk
  super(*args)
end

#inspectObject

Overrides the default Object#inspect to prevent mind-boggling circular displays in IRB.



97
98
99
# File 'lib/cheri/builder/base.rb', line 97

def inspect
 to_s  
end

#modObject

The builder module (such as Cheri::Swing) associated with this frame (builder object). Normally must be overridden. Default: Cheri::Builder::CheriModule



75
76
77
# File 'lib/cheri/builder/base.rb', line 75

def mod
  CheriModule  
end

#objectObject

The object for this frame (builder). Normally the object being built, once it has been created. May be the same as the builder object (see Cheri::Html::Elem, for example).



69
70
71
# File 'lib/cheri/builder/base.rb', line 69

def object
  @obj
end

#parent?Boolean

Override to return true if object can be a parent of other objects. Default: false

Returns:

  • (Boolean)


80
81
82
# File 'lib/cheri/builder/base.rb', line 80

def parent?
  false
end

#runObject

Perform whatever actions are required to build object. Normally overridden to create object and call its block, if any. Should return the built object.

The default implementation simply calls block, if present. (Note that the block is actually called indirectly, via Cheri::Builder::Context#call, which manages the stack and connections. You normally do not want to call the block directly.)



63
64
65
# File 'lib/cheri/builder/base.rb', line 63

def run
  @ctx.call(self,&@blk) if @blk
end