Class: Glimmer::DSL::Expression
- Inherits:
-
Object
- Object
- Glimmer::DSL::Expression
- Defined in:
- lib/glimmer/dsl/expression.rb
Overview
Represents a Glimmer DSL expression (e.g. label(:center) { … })
An expression object can interpret a keyword, args, and a block into a UI object
Expressions subclasses follow the convention of using ‘and` and `or` english versino of Ruby’s boolean operations. This allows easy DSL-like readability of the rules, and easy tagging with pd when troubleshooting.
Direct Known Subclasses
ColorExpression, ComboSelectionDataBindingExpression, CustomWidgetExpression, DataBindingExpression, LayoutExpression, ListSelectionDataBindingExpression, PropertyExpression, StaticExpression, TableItemsDataBindingExpression, TreeItemsDataBindingExpression, WidgetExpression, WidgetListenerExpression
Instance Method Summary collapse
-
#add_content(parent, &block) ⇒ Object
Adds block content to specified parent UI object (Optional).
-
#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
Checks if it can interpret parameters (subclass must override).
-
#interpret(parent, keyword, *args, &block) ⇒ Object
Interprets parameters (subclass must override).
-
#textual?(object) ⇒ Boolean
Checks if object is a Symbol or a String.
-
#widget?(parent) ⇒ Boolean
Checks if parent object is a widget.
Instance Method Details
#add_content(parent, &block) ⇒ Object
Adds block content to specified parent UI object (Optional)
Only expressions that receive a content block should implement
26 27 28 |
# File 'lib/glimmer/dsl/expression.rb', line 26 def add_content(parent, &block) # No Op by default end |
#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean
Checks if it can interpret parameters (subclass must override)
14 15 16 |
# File 'lib/glimmer/dsl/expression.rb', line 14 def can_interpret?(parent, keyword, *args, &block) raise Error, "#can_interpret? must be implemented by an Expression subclass" end |
#interpret(parent, keyword, *args, &block) ⇒ Object
Interprets parameters (subclass must override)
19 20 21 |
# File 'lib/glimmer/dsl/expression.rb', line 19 def interpret(parent, keyword, *args, &block) raise Error, "#interpret must be implemented by an Expression subclass" end |
#textual?(object) ⇒ Boolean
Checks if object is a Symbol or a String
36 37 38 |
# File 'lib/glimmer/dsl/expression.rb', line 36 def textual?(object) object.is_a?(Symbol) or object.is_a?(String) end |
#widget?(parent) ⇒ Boolean
Checks if parent object is a widget
31 32 33 |
# File 'lib/glimmer/dsl/expression.rb', line 31 def (parent) parent.is_a?(SWT::WidgetProxy) or parent.is_a?(UI::CustomWidget) end |