Class: Raf::HeadIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/rafelement.rb

Instance Method Summary collapse

Constructor Details

#initializeHeadIndex

Returns a new instance of HeadIndex.



7
8
9
10
# File 'lib/rafelement.rb', line 7

def initialize
  @head_index = []
  @point_pre = 0
end

Instance Method Details

#clearObject



32
33
34
# File 'lib/rafelement.rb', line 32

def clear
  @heade_index = [0,0,0,0,0,0,0]
end

#to_sObject



25
26
27
28
29
30
# File 'lib/rafelement.rb', line 25

def to_s
  @head_index.map{|n|
    n = 0 if n.nil?
    n
  }.join(".") + "."
end

#update(level) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rafelement.rb', line 12

def update(level)
  point = level - 2
  if @point_pre > point
    (@point_pre - point).times do
      @head_index.pop
      @point_pre -= 1
    end
  end
  @head_index[point] ||= 0
  @head_index[point] += 1
  @point_pre = point
end