Class: Characterize::ControllerMacros::Converter
- Inherits:
-
Object
- Object
- Characterize::ControllerMacros::Converter
- Defined in:
- lib/characterize/controller.rb
Instance Method Summary collapse
-
#initialize(string) ⇒ Converter
constructor
A new instance of Converter.
- #to_constant_name ⇒ Object
- #to_object_name ⇒ Object
- #to_path ⇒ Object
Constructor Details
#initialize(string) ⇒ Converter
Returns a new instance of Converter.
54 55 56 |
# File 'lib/characterize/controller.rb', line 54 def initialize(string) @string = string.to_s end |
Instance Method Details
#to_constant_name ⇒ Object
67 68 69 70 |
# File 'lib/characterize/controller.rb', line 67 def to_constant_name @string.gsub(/(?:^|_)([a-z])/){ $1.upcase }.gsub('/','::') # TODO: get platform-specific path delimiter end |
#to_object_name ⇒ Object
58 59 60 |
# File 'lib/characterize/controller.rb', line 58 def to_object_name to_path.split('/').last end |
#to_path ⇒ Object
62 63 64 65 |
# File 'lib/characterize/controller.rb', line 62 def to_path # TODO: get platform-specific path delimiter @string.gsub('::','/').gsub(/([A-Z])/){ "_#{$1.downcase}" }.gsub(/^_|\/_/,'/').sub(/^\//,'') end |