Class: TwitterCldr::Utils::FileSystemTrie::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/twitter_cldr/utils/file_system_trie.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value = nil, children = {}) ⇒ Node

Returns a new instance of Node.



112
113
114
115
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 112

def initialize(value = nil, children = {})
  @value    = value
  @children = children
end

Instance Attribute Details

#childrenObject

Returns the value of attribute children.



110
111
112
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 110

def children
  @children
end

#valueObject

Returns the value of attribute value.



110
111
112
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 110

def value
  @value
end

Instance Method Details

#child(key) ⇒ Object



117
118
119
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 117

def child(key)
  @children[key]
end

#each_key_and_child(&block) ⇒ Object



129
130
131
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 129

def each_key_and_child(&block)
  @children.each(&block)
end

#has_children?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 125

def has_children?
  !@children.empty?
end

#keysObject



133
134
135
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 133

def keys
  @children.keys
end

#set_child(key, child) ⇒ Object



121
122
123
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 121

def set_child(key, child)
  @children[key] = child
end

#to_trieObject



137
138
139
# File 'lib/twitter_cldr/utils/file_system_trie.rb', line 137

def to_trie
  Trie.new(self.class.new(nil, @children)).lock
end