Class: Okura::WordDic::DoubleArray::Builder::Node
- Inherits:
-
Object
- Object
- Okura::WordDic::DoubleArray::Builder::Node
- Defined in:
- lib/okura/word_dic.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#data_id ⇒ Object
readonly
Returns the value of attribute data_id.
Instance Method Summary collapse
- #add(bytes, idx, data_id) ⇒ Object
- #has_data? ⇒ Boolean
-
#initialize ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
171 172 173 174 |
# File 'lib/okura/word_dic.rb', line 171 def initialize @data_id=nil @children={} end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
176 177 178 |
# File 'lib/okura/word_dic.rb', line 176 def children @children end |
#data_id ⇒ Object (readonly)
Returns the value of attribute data_id.
175 176 177 |
# File 'lib/okura/word_dic.rb', line 175 def data_id @data_id end |
Instance Method Details
#add(bytes, idx, data_id) ⇒ Object
180 181 182 183 184 185 186 187 |
# File 'lib/okura/word_dic.rb', line 180 def add bytes,idx,data_id if idx==bytes.length @data_id=data_id else c=bytes[idx] (@children[c]||=Node.new).add(bytes,idx+1,data_id) end end |
#has_data? ⇒ Boolean
177 178 179 |
# File 'lib/okura/word_dic.rb', line 177 def has_data? !!data_id end |