Class: Drone::Storage::SharedNumber

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(initial_value) ⇒ SharedNumber

Constructor

Parameters:

  • initial_value (Number)

    The initial value



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.

Parameters:

  • expected (Number)

    The expected current value

  • new_value (Number)

    The new value



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

Parameters:

  • n (Number) (defaults to: 1)

    Decrement by n



32
33
34
# File 'lib/drone/storage/base.rb', line 32

def dec(n = 1)
  raise "needs to be redefined"
end

#getNumber

Get the current value

Returns:

  • (Number)

    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

Parameters:

  • n (Number)

    The new value

Returns:

  • (Number)

    The old value



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

Parameters:

  • n (Number) (defaults to: 1)

    Increment by n



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

Parameters:

  • n (Number)

    The new value



41
42
43
# File 'lib/drone/storage/base.rb', line 41

def set(n)
  raise "needs to be redefined"
end