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 printout with puts_debuggerer when troubleshooting.
Direct Known Subclasses
Class Method Summary collapse
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.
Class Method Details
.dsl ⇒ Object
35 36 37 |
# File 'lib/glimmer/dsl/expression.rb', line 35 def dsl @dsl ||= name.split(/::/)[-2].downcase.to_sym end |
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
53 54 55 |
# File 'lib/glimmer/dsl/expression.rb', line 53 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)
41 42 43 |
# File 'lib/glimmer/dsl/expression.rb', line 41 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)
46 47 48 |
# File 'lib/glimmer/dsl/expression.rb', line 46 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
58 59 60 |
# File 'lib/glimmer/dsl/expression.rb', line 58 def textual?(object) object.is_a?(Symbol) or object.is_a?(String) end |