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.
338
339
340
341
|
# File 'lib/hermeneutics/escape.rb', line 338
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
359
360
361
362
363
364
365
366
367
368
369
370
|
# File 'lib/hermeneutics/escape.rb', line 359
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
332
333
334
335
336
|
# File 'lib/hermeneutics/escape.rb', line 332
def create
i = new
yield i
i
end
|
Instance Method Details
#[](key) ⇒ Object
342
343
344
|
# File 'lib/hermeneutics/escape.rb', line 342
def [] key
super key.to_sym
end
|
#[]=(key, val) ⇒ Object
345
346
347
|
# File 'lib/hermeneutics/escape.rb', line 345
def []= key, val
super key.to_sym, val
end
|
#parse(key, val) ⇒ Object
352
353
354
355
356
357
358
|
# File 'lib/hermeneutics/escape.rb', line 352
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!
348
349
350
|
# File 'lib/hermeneutics/escape.rb', line 348
def update hash
hash.each { |k,v| self[ k] = v }
end
|