Class | Origami::Dictionary |
In: |
sources/parser/dictionary.rb
sources/parser/obfuscation.rb |
Parent: | Hash |
Class representing a Dictionary Object. Dictionaries are containers associating a Name to an embedded Object.
to_hash | -> | to_h |
each_value | -> | each |
to_h | -> | value |
Creates a new Dictionary.
hash: | The hash representing the new Dictionary. |
# File sources/parser/dictionary.rb, line 47 47: def initialize(hash = {}) 48: 49: unless hash.is_a?(Hash) 50: raise TypeError, "Expected type Hash, received #{hash.class}." 51: end 52: 53: super() 54: 55: hash.each_key { |k| 56: self[k.to_o] = hash[k].to_o unless k.nil? 57: } 58: 59: end
# File sources/parser/dictionary.rb, line 122 122: def []=(key,val) 123: 124: unless key.is_a?(Symbol) or key.is_a?(Name) 125: fail "Expecting a Name for a Dictionary entry, found #{key.class} instead." 126: end 127: 128: key = key.to_o 129: if not val.nil? 130: val = val.to_o 131: super(key,val) 132: 133: val.parent = self 134: 135: val 136: else 137: delete(key) 138: end 139: end
# File sources/parser/dictionary.rb, line 110 110: def map!(&b) 111: 112: self.each_pair { |k,v| 113: self[k] = b.call(v) 114: } 115: 116: end
# File sources/parser/dictionary.rb, line 118 118: def merge(dict) 119: Dictionary.new(super(dict)) 120: end
# File sources/parser/obfuscation.rb, line 117 117: def to_obfuscated_str 118: content = TOKENS.first + Obfuscator.junk_spaces 119: self.each_pair { |key, value| 120: content << Obfuscator.junk_spaces + 121: key.to_obfuscated_str + Obfuscator.junk_spaces + 122: value.to_obfuscated_str + Obfuscator.junk_spaces 123: } 124: 125: content << TOKENS.last 126: super(content) 127: end