Class: NLP::Category
- Inherits:
-
Object
show all
- Defined in:
- lib/dictionaries/category.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(name, parent = nil) ⇒ Category
5
6
7
8
|
# File 'lib/dictionaries/category.rb', line 5
def initialize(name, parent = nil)
@parent = parent
@name = name.to_sym
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
3
4
5
|
# File 'lib/dictionaries/category.rb', line 3
def name
@name
end
|
#parent ⇒ Object
Returns the value of attribute parent.
3
4
5
|
# File 'lib/dictionaries/category.rb', line 3
def parent
@parent
end
|
Instance Method Details
#path ⇒ Object
10
11
12
|
# File 'lib/dictionaries/category.rb', line 10
def path
@parent ? (@parent.path + '/' + name.to_s) : name.to_s
end
|
#root ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/dictionaries/category.rb', line 14
def root
category = self
while category.parent != nil
category = category.parent
end
category.name
end
|
#to_s ⇒ Object
22
23
24
|
# File 'lib/dictionaries/category.rb', line 22
def to_s
"#{path.inspect}"
end
|