lib/esse/primitives/hstring.rb in esse-0.0.5 vs lib/esse/primitives/hstring.rb in esse-0.1.1

- old
+ new

@@ -7,11 +7,11 @@ # monkey patching. # And on this state and not thinking about to add ActiveSupport dependency class Hstring extend Forwardable - def_delegators :@value, :==, :eq, :to_s, :inspect, :sub, :capitalize + def_delegators :@value, :==, :eq, :to_s, :to_sym, :inspect, :sub, :capitalize attr_reader :value def self.def_conventional(bang_method, conv_method = nil) conv_method ||= bang_method.to_s.sub(/[!?]*$/, '') if public_instance_methods.include?(conv_method) @@ -52,21 +52,22 @@ self end def_conventional :demodulize! def modulize! - @value = @value.split(%r{\:\:|\\|/}).map { |part| self.class.new(part).camelize.to_s }.join('::') + @value = @value.split(%r{::|\\|/}).map { |part| self.class.new(part).camelize.to_s }.join('::') self end def_conventional :modulize! def underscore! @value = @value - .sub(/^\:\:/, '') + .sub(/^::/, '') .gsub('::', '/') .gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') + .tr('.', '_') .gsub(/\s/, '_') .gsub(/__+/, '_') .downcase self