Class: ODDB::WhoPlugin::CodeHandler

Inherits:
Object
  • Object
show all
Defined in:
src/plugin/who.rb

Constant Summary

ATC_TOP_LEVEL =
%w{A B C D G H J L M N P R S V}

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (CodeHandler) initialize

A new instance of CodeHandler



16
17
18
19
# File 'src/plugin/who.rb', line 16

def initialize
  @queue = ATC_TOP_LEVEL.dup
  @visited = []
end

Instance Attribute Details

- (Object) queue (readonly)

Returns the value of attribute queue



15
16
17
# File 'src/plugin/who.rb', line 15

def queue
  @queue
end

- (Object) visited (readonly)

Returns the value of attribute visited



15
16
17
# File 'src/plugin/who.rb', line 15

def visited
  @visited
end

Instance Method Details

- (Object) push(code)



20
21
22
23
24
# File 'src/plugin/who.rb', line 20

def push(code)
  unless((@queue + @visited).include?(code))
    @queue.push(code)
  end
end

- (Object) shift



25
26
27
28
29
# File 'src/plugin/who.rb', line 25

def shift
  code = @queue.shift
  @visited.push(code) if code
  code
end