Module: RhGet
Overview
Module to implement common function for Hash and Array class
Instance Method Summary collapse
- #_key_options(opts) ⇒ Object
- #_key_to_s(k) ⇒ Object
- #_loop_on_regs(regs, key) ⇒ Object
- #_regexp(key) ⇒ Object
- #_update_res(res, k, v, one) ⇒ Object
Instance Method Details
#_key_options(opts) ⇒ Object
219 220 221 222 223 224 225 |
# File 'lib/rh.rb', line 219 def (opts) empty = false empty = opts.include?('e') if opts one = false one = opts.include?('0') if opts [empty, one] end |
#_key_to_s(k) ⇒ Object
236 237 238 239 |
# File 'lib/rh.rb', line 236 def _key_to_s(k) return ':' + k.to_s if k.is_a?(Symbol) k end |
#_loop_on_regs(regs, key) ⇒ Object
227 228 229 230 231 232 233 234 |
# File 'lib/rh.rb', line 227 def _loop_on_regs(regs, key) regs.each do |r| init = r[1] reg = r[0].match(key) return [Regexp.new(reg[1]), init, reg[2]] if reg && reg[1] end [nil, nil, nil] end |
#_regexp(key) ⇒ Object
207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/rh.rb', line 207 def _regexp(key) return [key, [], nil] if key.is_a?(Regexp) return [nil, nil, nil] unless key.is_a?(String) regs = [] regs << [%r{^/(.*)/([e0])*$}, []] regs << [%r{^\[/(.*)/([e0])*\]$}, []] regs << [%r{^\{/(.*)/([e0])*\}$}, {}] _loop_on_regs(regs, key) end |