Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 537feca812
Fetching contributors…

Cannot retrieve contributors at this time

45 lines (35 sloc) 0.774 kB
require 'rubygems'
$LOAD_PATH.unshift './lib'
require 'cplus2ruby'
class NeuralEntity; cplus2ruby
property :id
end
class Neuron < NeuralEntity
property :potential, :float
property :last_spike_time, :float
property :pre_synapses
method :stimulate, {:at => :float},{:weight => :float}, %{
// This is C++ Code
@potential += at*weight;
// call a Ruby method
log(@potential);
}
stub_method :log, {:pot => :float}
def log(pot)
puts "log(#{pot})"
end
def initialize
self.pre_synapses = []
end
end
if __FILE__ == $0
#
# Generate C++ code, compile and load shared library.
#
Cplus2Ruby.commit('work/neural')
n = Neuron.new
n.id = "n1"
n.potential = 1.0
n.stimulate(1.0, 2.0)
p n.potential # => 3.0
end
Jump to Line
Something went wrong with that request. Please try again.