Class: Drone::Storage::SharedNumber
- Inherits:
-
Object
- Object
- Drone::Storage::SharedNumber
- Defined in:
- lib/drone/storage/base.rb
Overview
Represents a number but procide a specific api allowing this number to shared anywhere
Instance Method Summary collapse
-
#compare_and_set(expected, new_value) ⇒ Object
Set the new value but only if the current value is equal to expected.
-
#dec(n = 1) ⇒ Object
Decrement the value.
-
#get ⇒ Number
Get the current value.
-
#get_and_set(n) ⇒ Number
Set a new value and return the old one.
-
#inc(n = 1) ⇒ Object
Increment the value.
-
#initialize(initial_value) ⇒ SharedNumber
constructor
Constructor.
-
#set(n) ⇒ Object
Set the value.
Constructor Details
#initialize(initial_value) ⇒ SharedNumber
Constructor
14 15 16 |
# File 'lib/drone/storage/base.rb', line 14 def initialize(initial_value) raise "needs to be redefined" end |
Instance Method Details
#compare_and_set(expected, new_value) ⇒ Object
Set the new value but only if the current value is equal to expected.
72 73 74 |
# File 'lib/drone/storage/base.rb', line 72 def compare_and_set(expected, new_value) raise "needs to be redefined" end |
#dec(n = 1) ⇒ Object
Decrement the value
32 33 34 |
# File 'lib/drone/storage/base.rb', line 32 def dec(n = 1) raise "needs to be redefined" end |
#get ⇒ Number
Get the current value
50 51 52 |
# File 'lib/drone/storage/base.rb', line 50 def get raise "needs to be redefined" end |
#get_and_set(n) ⇒ Number
Set a new value and return the old one
61 62 63 |
# File 'lib/drone/storage/base.rb', line 61 def get_and_set(n) raise "needs to be redefined" end |
#inc(n = 1) ⇒ Object
Increment the value
23 24 25 |
# File 'lib/drone/storage/base.rb', line 23 def inc(n = 1) raise "needs to be redefined" end |
#set(n) ⇒ Object
Set the value
41 42 43 |
# File 'lib/drone/storage/base.rb', line 41 def set(n) raise "needs to be redefined" end |