Class: Improvise::Dictionary
- Inherits:
-
Object
- Object
- Improvise::Dictionary
show all
- Defined in:
- lib/improvise/dictionary.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(depth = 2, tree = nil) ⇒ Dictionary
Returns a new instance of Dictionary.
8
9
10
11
|
# File 'lib/improvise/dictionary.rb', line 8
def initialize(depth=2, tree=nil)
@depth = depth
@tree = tree || DictionaryTree.new
end
|
Instance Attribute Details
#depth ⇒ Object
Returns the value of attribute depth.
6
7
8
|
# File 'lib/improvise/dictionary.rb', line 6
def depth
@depth
end
|
Class Method Details
.json_create(json_hash) ⇒ Object
25
26
27
|
# File 'lib/improvise/dictionary.rb', line 25
def self.json_create(json_hash)
new(json_hash['depth'], json_hash['tree'])
end
|
Instance Method Details
#as_json(opts = {}) ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/improvise/dictionary.rb', line 13
def as_json(opts = {})
{
JSON.create_id => self.class.name,
'depth' => @depth,
'tree' => @tree.as_json
}
end
|
#to_json(*a) ⇒ Object
21
22
23
|
# File 'lib/improvise/dictionary.rb', line 21
def to_json(*a)
as_json.to_json(*a)
end
|