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
275 276 277 278 279 280 281 282 283 284 285 |
# File 'lib/csl/treelike.rb', line 275 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.
267 268 269 270 271 272 273 |
# File 'lib/csl/treelike.rb', line 267 def create_children if const?(:Children) const_get(:Children).new else [] end end |