Class: Glimmer::DSL::Tk::VariableListenerExpression

Inherits:
Expression
  • Object
show all
Defined in:
lib/glimmer/dsl/tk/variable_listener_expression.rb

Instance Method Summary collapse

Instance Method Details

#can_interpret?(parent, keyword, *args, &block) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/glimmer/dsl/tk/variable_listener_expression.rb', line 29

def can_interpret?(parent, keyword, *args, &block)
  parent.is_a?(Glimmer::Tk::WidgetProxy) && keyword.match(/^on_.*/) && textual?(args.first)
end

#interpret(parent, keyword, *args, &block) ⇒ Object



33
34
35
36
37
# File 'lib/glimmer/dsl/tk/variable_listener_expression.rb', line 33

def interpret(parent, keyword, *args, &block)
  variable_name = keyword.sub(/^on_/, '')
  operation = args.first.to_s
  parent.tk.send(variable_name).trace(operation, &block)
end