Class: Device::Support
- Inherits:
-
Object
- Object
- Device::Support
- Defined in:
- lib/device/support.rb
Class Method Summary collapse
- .camelize(str) ⇒ Object
- .class_to_path(klass) ⇒ Object
- .constantize(name) ⇒ Object
- .path_to_class(path) ⇒ Object
- .remove_extension(path) ⇒ Object
Class Method Details
.camelize(str) ⇒ Object
11 12 13 |
# File 'lib/device/support.rb', line 11 def self.camelize(str) str.split('_').map {|w| w.capitalize}.join end |
.class_to_path(klass) ⇒ Object
3 4 5 |
# File 'lib/device/support.rb', line 3 def self.class_to_path(klass) klass.to_s.downcase end |
.constantize(name) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/device/support.rb', line 19 def self.constantize(name) if ! name.empty? && Object.const_defined?(name) Object.const_get name else nil end end |
.path_to_class(path) ⇒ Object
7 8 9 |
# File 'lib/device/support.rb', line 7 def self.path_to_class(path) constantize(camelize(remove_extension(path))) end |
.remove_extension(path) ⇒ Object
15 16 17 |
# File 'lib/device/support.rb', line 15 def self.remove_extension(path) path.to_s.split(".")[-2].split("/").last end |