Class: Andromeda::Atom::Region

Inherits:
Object
  • Object
show all
Includes:
Impl::To_S
Defined in:
lib/andromeda/atom.rb

Instance Method Summary collapse

Methods included from Impl::To_S

short_s, #to_s

Constructor Details

#initialize(init_value = 0) ⇒ Region

Returns a new instance of Region.

Raises:

  • (ArgumentError)


55
56
57
58
59
# File 'lib/andromeda/atom.rb', line 55

def initialize(init_value = 0)
	init_value = init_value[:init_value].to_i if init_value.kind_of?(Hash)
	raise ArgumentError unless init_value.kind_of?(Fixnum)
	@count = Impl::Atom.new init_value
end

Instance Method Details

#enter(amount = 1) ⇒ Object

Raises:

  • (ArgumentError)


65
66
67
68
69
# File 'lib/andromeda/atom.rb', line 65

def enter(amount = 1)
	raise ArgumentError unless amount.kind_of?(Fixnum)
	raise ArgumentError unless amount >= 0
	@count.update { |v| v + amount }
end

#leave(amount = 1) ⇒ Object

Raises:

  • (ArgumentError)


71
72
73
74
75
# File 'lib/andromeda/atom.rb', line 71

def leave(amount = 1)
	raise ArgumentError unless amount >= 0
	raise ArgumentError unless amount.kind_of?(Fixnum)
	@count.update { |v| v - amount }
end

#to_short_sObject



52
# File 'lib/andromeda/atom.rb', line 52

def to_short_s ; "(#{Impl::To_S.short_s(value)})" end

#valueObject



63
# File 'lib/andromeda/atom.rb', line 63

def value ; @count.value end

#wait_until_eq(val) ⇒ Object



77
# File 'lib/andromeda/atom.rb', line 77

def wait_until_eq(val) ; @count.wait_until_eq(val) end