Class: SWT::SimpleCommand

Inherits:
TreeCommand show all
Defined in:
lib/swt.rb

Instance Method Summary collapse

Methods inherited from TreeCommand

#stacktrace

Constructor Details

#initialize(parent, child = nil) ⇒ SimpleCommand


41
42
43
44
# File 'lib/swt.rb', line 41

def initialize(parent,child=nil)
  super(parent)
  @child=child
end

Instance Method Details

#accept(child) ⇒ Object


45
46
47
# File 'lib/swt.rb', line 45

def accept(child)
  @child=child
end

#invoke(tree) ⇒ Object


48
49
50
51
52
53
# File 'lib/swt.rb', line 48

def invoke(tree)
  @child=@child.call if @child.is_a? Proc
  raise "Link expression must evaluate to command: #{stacktrace}" unless @child
  tree=[tree] unless tree.is_a? Array
  @child.invoke tree
end

#to_sObject


54
55
56
# File 'lib/swt.rb', line 54

def to_s
  "#{self.class} (#{@child})"
end