Class: Hermeneutics::URLText::Dict
- Inherits:
-
Hash
- Object
- Hash
- Hermeneutics::URLText::Dict
show all
- Defined in:
- lib/hermeneutics/escape.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize {|_self| ... } ⇒ Dict
Returns a new instance of Dict.
325
326
327
328
|
# File 'lib/hermeneutics/escape.rb', line 325
def initialize
super
yield self if block_given?
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args) ⇒ Object
347
348
349
350
351
352
353
354
355
356
357
358
|
# File 'lib/hermeneutics/escape.rb', line 347
def method_missing sym, *args
if args.empty? and not sym =~ /[!?=]\z/ then
self[ sym]
else
first, *rest = args
if rest.empty? and sym =~ /=\z/ then
self[ sym] = first
else
super
end
end
end
|
Class Method Details
.create {|i| ... } ⇒ Object
319
320
321
322
323
|
# File 'lib/hermeneutics/escape.rb', line 319
def create
i = new
yield i
i
end
|
Instance Method Details
#[](key) ⇒ Object
329
330
331
|
# File 'lib/hermeneutics/escape.rb', line 329
def [] key
super key.to_sym
end
|
#[]=(key, val) ⇒ Object
332
333
334
|
# File 'lib/hermeneutics/escape.rb', line 332
def []= key, val
super key.to_sym, val
end
|
#parse(key, val) ⇒ Object
339
340
341
342
343
344
345
|
# File 'lib/hermeneutics/escape.rb', line 339
def parse key, val
self[ key] = case val
when nil then nil
when /\A(?:[+-]?[1-9][0-9]{,9}|0)\z/ then val.to_i
else val.to_s.notempty?
end
end
|
#update(hash) ⇒ Object
Also known as:
merge!
335
336
337
|
# File 'lib/hermeneutics/escape.rb', line 335
def update hash
hash.each { |k,v| self[ k] = v }
end
|