Sha256: 1c06fc165a49755140835090d2bb07b593bb8e76e24851fd795531c2a5e979bc
Contents?: true
Size: 1.43 KB
Versions: 3
Compression:
Stored size: 1.43 KB
Contents
module Quickl module Naming # # Converts a command name to a module name. Implements # the following conversions: # # hello -> Hello # hello-world -> HelloWorld # # This method is part of Quickl's private interface even # if its effect are considered public. # def command2module(name) case name when String name.gsub(/^(.)|-(.)/){|x| x.upcase}.gsub(/-/,'') when Symbol command2module(name.to_s).to_sym else raise ArgumentError, "Invalid name argument #{name.class}" end end # # Converts a module name to a command name. Implements the # following conversions: # # Hello -> hello # HelloWorld -> hello-world # # This method is part of Quickl's private interface even # if its effect are considered public. # def module2command(mod) case mod when Module name = RubyTools::class_unqualified_name(mod) name = name.gsub(/[A-Z]/){|x| "-#{x.downcase}"}[1..-1] when String name = mod.to_s name = name.gsub(/[A-Z]/){|x| "-#{x.downcase}"}[1..-1] when Symbol name = mod.to_s name = name.gsub(/[A-Z]/){|x| "-#{x.downcase}"}[1..-1] name.to_sym else raise ArgumentError, "Invalid module argument #{mod.class}" end end end # module Naming end # module Quickl
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
quickl-0.2.1 | lib/quickl/naming.rb |
quickl-0.2.0 | lib/quickl/naming.rb |
quickl-0.1.1 | lib/quickl/naming.rb |