Class: TwitterCldr::Utils::FileSystemTrie
- Inherits:
-
Object
- Object
- TwitterCldr::Utils::FileSystemTrie
- Defined in:
- lib/twitter_cldr/utils/file_system_trie.rb
Defined Under Namespace
Classes: Node
Constant Summary collapse
- VALUE_FILE =
'value.dump'
Instance Attribute Summary collapse
-
#path_root ⇒ Object
readonly
Returns the value of attribute path_root.
Instance Method Summary collapse
- #add(key, value) ⇒ Object
- #empty? ⇒ Boolean
- #get(key) ⇒ Object
- #get_node(key) ⇒ Object
-
#initialize(path_root, root = Node.new) ⇒ FileSystemTrie
constructor
A new instance of FileSystemTrie.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(path_root, root = Node.new) ⇒ FileSystemTrie
Returns a new instance of FileSystemTrie.
17 18 19 20 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 17 def initialize(path_root, root = Node.new) @path_root = path_root @root = root end |
Instance Attribute Details
#path_root ⇒ Object (readonly)
Returns the value of attribute path_root.
15 16 17 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 15 def path_root @path_root end |
Instance Method Details
#add(key, value) ⇒ Object
26 27 28 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 26 def add(key, value) store(key, value, false) end |
#empty? ⇒ Boolean
22 23 24 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 22 def empty? !@root.has_children? end |
#get(key) ⇒ Object
34 35 36 37 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 34 def get(key) node = get_node(key) node && node.value end |
#get_node(key) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 39 def get_node(key) traverse(key) do |node, key_element| return unless node node.child(key_element) end end |
#set(key, value) ⇒ Object
30 31 32 |
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 30 def set(key, value) store(key, value) end |