Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class String
- def scan_then_inject
- scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h }
- end
- def scan_groups_then_inject
- scan(/\w+=\w+/).inject({}) { |h,opt| kv = opt.split('='); h[kv.first] = kv.last; h }
- end
- def scan_then_splat_hash
- Hash[*scan(/(\w+)=(\w+)/).flatten]
- end
- def split_then_splat_hash
- Hash[*split(/&|=/)]
- end
- end
Add Comment
Please, Sign In to add comment