Class: RDL::Switch

Inherits:
Object show all
Defined in:
lib/rdl/switch.rb

Instance Method Summary collapse

Constructor Details

#initializeSwitch

Returns a new instance of Switch.



2
3
4
# File 'lib/rdl/switch.rb', line 2

def initialize
  @switch = true
end

Instance Method Details

#offObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/rdl/switch.rb', line 8

def off()
  return unless @switch
  tmp = @switch
  @switch = false
  begin
    ret = yield
  ensure
    @switch = tmp
  end
  return ret
end

#off?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/rdl/switch.rb', line 5

def off?()
  return not(@switch)
end