Class: Hash
- Includes:
- Compact, Cross, EnsureKeys, Extract, Extras
- Defined in:
- lib/vex/base/hash/slop.rb,
lib/vex/boot/hash.rb,
lib/vex/base/hash/cross.rb,
lib/vex/base/hash/extras.rb,
lib/vex/base/hash/compact.rb,
lib/vex/base/hash/extract.rb,
lib/vex/base/hash/inspect.rb,
lib/vex/base/hash/ensure_keys.rb,
lib/vex/base/object/insp.rb
Overview
-
allows to use hash.xx.yy where you would have to use
hash[:yy] etc.
-
supports
hash.xx?
as a shortcut for hash.key?(:xx) || hash.key?(“xx”)
-
does not support assignment, though; i.e.
hash.yy = zz
will raise a NoMethodError.
Defined Under Namespace
Modules: Compact, Cross, EnsureKeys, Etest, Extract, Extras, Slop
Instance Method Summary collapse
- #delete_multi(a0, *extras, &block) ⇒ Object (also: #delete)
- #insp ⇒ Object
- #inspect ⇒ Object
- #slop! ⇒ Object
- #sloppy? ⇒ Boolean
Methods included from EnsureKeys
Methods included from Extract
Methods included from Compact
Methods included from Extras
#delete_all, #hmap, included, #select_entries
Methods included from Cross
Instance Method Details
#delete_multi(a0, *extras, &block) ⇒ Object Also known as: delete
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/vex/boot/hash.rb', line 4 def delete_multi(a0, *extras, &block) if extras.empty? || block_given? delete_single a0, *extras, &block else r = [ delete_single(a0) ] extras.each do |arg| r.push delete_single(arg) end r end end |
#insp ⇒ Object
47 48 49 |
# File 'lib/vex/base/object/insp.rb', line 47 def insp self.class == Hash && instance_variables.empty? ? insp_body : super end |
#inspect ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/vex/base/hash/inspect.rb', line 3 def inspect "{" + to_a.sort_by do |k, v| k.to_s end.map do |k,v| "#{k.inspect} => #{v.inspect}" end.join(", ") + "}" end |