Class: Util
- Inherits:
-
Object
- Object
- Util
- Defined in:
- lib/twitter_meme/util.rb
Class Method Summary collapse
Class Method Details
.split_text(text) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/twitter_meme/util.rb', line 2 def self.split_text(text) i = text[0..(text.length / 2)].rindex(' ') if i.nil? if include?(' ') split(' ', 1) else [text, ''] end else [text[0..i].strip, text[i..-1].strip] end end |
.symbolize_keys(obj) ⇒ Object
15 16 17 18 19 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 45 46 47 |
# File 'lib/twitter_meme/util.rb', line 15 def self.symbolize_keys(obj) case obj when Array obj.inject([]){|res, val| res << case val when Hash, Array symbolize_keys(val) else val end res } when Hash obj.inject({}){|res, (key, val)| nkey = case key when String key.to_sym else key end nval = case val when Hash, Array symbolize_keys(val) else val end res[nkey] = nval res } else obj end end |