Module: CSL::Treelike::ClassMethods
- Defined in:
- lib/csl/treelike.rb
Instance Method Summary collapse
- #constantize_nodename(name) ⇒ Object
-
#create_children ⇒ Object
Returns a new instance of an Array or Struct to manage the Node’s children.
Instance Method Details
#constantize_nodename(name) ⇒ Object
264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/csl/treelike.rb', line 264 def constantize_nodename(name) return constantize(name) if respond_to?(:constantize) klass = name.to_s.capitalize.gsub(/(\w)-(\w)/) { [$1, $2.upcase].join } if const_defined?(klass) const_get(klass) else nil end end |
#create_children ⇒ Object
Returns a new instance of an Array or Struct to manage the Node’s children. This method is called automatically by the Node’s constructor.
256 257 258 259 260 261 262 |
# File 'lib/csl/treelike.rb', line 256 def create_children if const?(:Children) const_get(:Children).new else [] end end |