Class: Module
- Inherits:
-
Object
- Object
- Module
- Defined in:
- lib/maveric/extensions.rb
Class Method Summary collapse
-
.nesting_path_to_constant(path) ⇒ Object
Still deving this.
Instance Method Summary collapse
-
#to_path(flatten = false) ⇒ Object
Build a string akin to the absolute path of the nesting structure.
Class Method Details
.nesting_path_to_constant(path) ⇒ Object
Still deving this.
10 11 12 13 |
# File 'lib/maveric/extensions.rb', line 10 def self.nesting_path_to_constant path dig = proc{|c,n| c.const_get(n) } path.gsub(/_([a-z])/){$1.upcase}.split('/') end |
Instance Method Details
#to_path(flatten = false) ⇒ Object
Build a string akin to the absolute path of the nesting structure.
3 4 5 6 7 |
# File 'lib/maveric/extensions.rb', line 3 def to_path flatten=false path = '/'+self.to_s.gsub(/::+/, '/') # '^/' as absolute path. path = path.gsub(/([a-z])([A-Z])/,'\1_\2').sub(/\/Index$/,'/').downcase if flatten path end |