Class: ShellEvalContext

Inherits:
BasicObject
Includes:
Kernel
Defined in:
lib/roby/app/scripts/shell.rb

Instance Method Summary collapse

Constructor Details

#initialize(interface) ⇒ ShellEvalContext

Returns a new instance of ShellEvalContext.



107
108
109
110
111
# File 'lib/roby/app/scripts/shell.rb', line 107

def initialize(interface)
    @__interface = interface
    @__send = ::Queue.new
    @__results = ::Queue.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *args, &block) ⇒ Object



117
118
119
120
121
122
123
124
# File 'lib/roby/app/scripts/shell.rb', line 117

def method_missing(m, *args, &block)
    @__send.push(::Kernel.lambda { @__interface.send(m, *args, &block) })
    result, error = @__results.pop
    if error
        raise error
    else result
    end
end

Instance Method Details

#process_pendingObject



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/roby/app/scripts/shell.rb', line 126

def process_pending
    while true
        begin
            command = @__send.pop(true)
            begin
                result = command.call
                @__results.push([result, nil])
            rescue ::Exception => e
                @__results.push([nil, e])
            end
        rescue ::ThreadError
            break
        end
    end
end

#respond_to_missing?(m, include_private) ⇒ Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/roby/app/scripts/shell.rb', line 113

def respond_to_missing?(m, include_private)
    @__interface.respond_to?(m, include_private)
end