Class: Shacho::Util
- Inherits:
-
Object
- Object
- Shacho::Util
- Defined in:
- lib/shacho/util.rb
Class Method Summary collapse
-
.camelize(string) ⇒ Object
again, shamelessly ripped from active_support.
-
.constantize(camel_cased_word, constant) ⇒ Object
shamelessly ripped from active_support.
-
.help ⇒ Object
TODO make less horrible.
Class Method Details
.camelize(string) ⇒ Object
again, shamelessly ripped from active_support
15 16 17 |
# File 'lib/shacho/util.rb', line 15 def self.camelize(string) string.to_s.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase } end |
.constantize(camel_cased_word, constant) ⇒ Object
shamelessly ripped from active_support
4 5 6 7 8 9 10 11 12 |
# File 'lib/shacho/util.rb', line 4 def self.constantize(camel_cased_word, constant) names = camel_cased_word.split('::') names.shift if names.empty? || names.first.empty? names.each do |name| constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name) end constant end |
.help ⇒ Object
TODO make less horrible
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/shacho/util.rb', line 20 def self.help puts "USAGE" puts " shacho action params" puts puts " where `action` is one of the standard CRUDy actions: " puts " create" puts " use" puts " list" puts " which" puts " edit" puts " remove" puts " clear" puts puts " `params` refers to any additional parmeters you might want to pass in." puts " For now, that's just the name of the account" puts puts "EXAMPLES" puts " shacho create default" puts " shacho use default" puts " shacho list" puts " shacho which" puts " shacho edit default" puts " shacho remove default" puts " shacho clear" end |