Class: Brainz::Synapse
- Inherits:
-
Object
- Object
- Brainz::Synapse
- Defined in:
- lib/brainz/synapse.rb
Instance Attribute Summary collapse
-
#change ⇒ Object
Returns the value of attribute change.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Class Method Summary collapse
Instance Method Summary collapse
- #adjust(diff) ⇒ Object
-
#initialize(from, to) ⇒ Synapse
constructor
A new instance of Synapse.
Constructor Details
#initialize(from, to) ⇒ Synapse
Returns a new instance of Synapse.
6 7 8 9 10 |
# File 'lib/brainz/synapse.rb', line 6 def initialize(from, to) @weight = Kernel.rand(0.4) - 0.2 @change = 0 @from, @to = from, to end |
Instance Attribute Details
#change ⇒ Object
Returns the value of attribute change.
4 5 6 |
# File 'lib/brainz/synapse.rb', line 4 def change @change end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
3 4 5 |
# File 'lib/brainz/synapse.rb', line 3 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
3 4 5 |
# File 'lib/brainz/synapse.rb', line 3 def to @to end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
3 4 5 |
# File 'lib/brainz/synapse.rb', line 3 def weight @weight end |
Class Method Details
Instance Method Details
#adjust(diff) ⇒ Object
12 13 14 |
# File 'lib/brainz/synapse.rb', line 12 def adjust(diff) @weight += diff end |