Module: Refocus::PathHelper
Instance Method Summary collapse
-
#parent_and_name(name) ⇒ Object
Given a dot-separated string, returns the parent and name.
Instance Method Details
#parent_and_name(name) ⇒ Object
Given a dot-separated string, returns the parent and name. Returns nil for parent if there are no dots.
5 6 7 8 9 10 |
# File 'lib/refocus/path_helper.rb', line 5 def parent_and_name(name) array = name.split(".") parent = array.length == 1 ? nil : array[0..-2].join(".") name = array[-1] [parent, name] end |