Class: QDA::Backend::SQLite::CategoryTreeNode

Inherits:
Category
  • Object
show all
Defined in:
lib/weft/backend/sqlite/category_tree.rb

Instance Attribute Summary

Attributes inherited from Category

#children, #codes, #dbid, #memo, #meta, #name, #parent, #reader, #text

Instance Method Summary collapse

Methods inherited from Category

#==, #[], #ancestors, #code, #codetable=, #codetable_init, #delete, #descendants, #each_child, #escape_name, #find, #is_ancestor_of?, #is_descendant_of?, #num_of_chars, #num_of_codes, #num_of_docs, parse_path, #path, #uncode, #unique_name

Constructor Details

#initialize(parent, dbid, name) ⇒ CategoryTreeNode

Returns a new instance of CategoryTreeNode.



5
6
7
8
9
10
# File 'lib/weft/backend/sqlite/category_tree.rb', line 5

def initialize(parent, dbid, name)
  self.name = name 
  @parent  = parent
  @dbid = dbid
  @children = []
end

Instance Method Details

#add(dbid, name) ⇒ Object



12
13
14
# File 'lib/weft/backend/sqlite/category_tree.rb', line 12

def add(dbid, name)
  add_child( CategoryTreeNode.new(@dbid, dbid, name) )[-1]
end

#move(parent) ⇒ Object



16
17
18
19
# File 'lib/weft/backend/sqlite/category_tree.rb', line 16

def move(parent)
  @parent = parent.dbid
  parent.add_child(self)
end

#to_sObject Also known as: inspect



21
22
23
# File 'lib/weft/backend/sqlite/category_tree.rb', line 21

def to_s()
  "<CTNode '#{name}' [#{dbid}]>"
end