Class: Kaerukeyword

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/kaerukeyword.rb

Defined Under Namespace

Classes: DoubleArray, HashTree, LogicError, NotSupportError

Constant Summary collapse

VERSION =
'1.0.2'

Instance Method Summary collapse

Constructor Details

#initialize(key_array = nil, logic = :hash_tree) ⇒ Kaerukeyword

コンストラクタ 第2引数でデータ構造を選択できる



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/kaerukeyword.rb', line 50

def initialize(key_array = nil, logic = :hash_tree)
  @logic =
    case logic
    when :hash_tree
      HashTree.new(key_array)
    when :double_array
      raise NotSupportError, "double array will support, but doesn't yet"
      DoubleArray.new(key_array)
    else
      raise LogicError, "you have to select logic"
    end
end

Instance Method Details

#double_array!Object

ハッシュ木からダブル配列への変換

Raises:



66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/kaerukeyword.rb', line 66

def double_array!
  raise NotSupportError, "double array will support, but doesn't yet"
  raise LogicError, "already double array" if @logic.is_a?(DoubleArray)
  old_logic = @logic
  hash_tree = old_logic.tree

  @logic = DoubleArray.new
  @logic.construct_array(hash_tree, 0)

  old_logic = nil
  hash_tree = nil
  GC.start
  true
end