Class: Mapi::PropertySet::Key
- Inherits:
-
Object
- Object
- Mapi::PropertySet::Key
- Includes:
- Constants
- Defined in:
- lib/mapi/property_set.rb
Overview
+Properties+ are accessed by Keys, which are coerced to this class. Includes a bunch of methods (hash, ==, eql?) to allow it to work as a key in a +Hash+.
Also contains the code that maps keys to symbolic names.
Instance Attribute Summary collapse
- #code ⇒ Integer, String readonly
- #guid ⇒ Ole::Types::Clsid readonly
Instance Method Summary collapse
- #==(other) ⇒ Boolean (also: #eql?)
-
#hash ⇒ Integer
this stuff is to allow it to be a useful key.
-
#initialize(code, guid = PS_MAPI) ⇒ Key
constructor
A new instance of Key.
- #inspect ⇒ String
- #to_s ⇒ String
- #to_sym ⇒ Symbol
-
#transmittable? ⇒ Boolean
FIXME implement these.
Constructor Details
#initialize(code, guid = PS_MAPI) ⇒ Key
Returns a new instance of Key.
74 75 76 |
# File 'lib/mapi/property_set.rb', line 74 def initialize code, guid=PS_MAPI @code, @guid = code, guid end |
Instance Attribute Details
#code ⇒ Integer, String (readonly)
68 69 70 |
# File 'lib/mapi/property_set.rb', line 68 def code @code end |
#guid ⇒ Ole::Types::Clsid (readonly)
70 71 72 |
# File 'lib/mapi/property_set.rb', line 70 def guid @guid end |
Instance Method Details
#==(other) ⇒ Boolean Also known as: eql?
120 121 122 |
# File 'lib/mapi/property_set.rb', line 120 def == other hash == other.hash end |
#hash ⇒ Integer
this stuff is to allow it to be a useful key
115 116 117 |
# File 'lib/mapi/property_set.rb', line 115 def hash [code, guid].hash end |
#inspect ⇒ String
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/mapi/property_set.rb', line 127 def inspect # maybe the way to do this, would be to be able to register guids # in a global lookup, which are used by Clsid#inspect itself, to # provide symbolic names... guid_str = NAMES[guid] || "{#{guid.format}}" if Integer === code hex = '0x%04x' % code if guid == PS_MAPI # just display as plain hex number hex else "#<Key #{guid_str}/#{hex}>" end else # display full guid and code "#<Key #{guid_str}/#{code.inspect}>" end end |
#to_s ⇒ String
103 104 105 |
# File 'lib/mapi/property_set.rb', line 103 def to_s to_sym.to_s end |
#to_sym ⇒ Symbol
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/mapi/property_set.rb', line 79 def to_sym # hmmm, for some stuff, like, eg, the message class specific range, sym-ification # of the key depends on knowing our message class. i don't want to store anything else # here though, so if that kind of thing is needed, it can be passed to this function. # worry about that when some examples arise. case code when Integer if guid == PS_MAPI # and < 0x8000 ? # the hash should be updated now that i've changed the process TAGS['%04x' % code].first[/_(.*)/, 1].downcase.to_sym rescue code else # handle other guids here, like mapping names to outlook properties, based on the # outlook object model. NAMED_MAP[self].to_sym rescue code end when String # return something like # note that named properties don't go through the map at the moment. so #categories # doesn't work yet code.downcase.to_sym end end |
#transmittable? ⇒ Boolean
FIXME implement these
108 109 110 |
# File 'lib/mapi/property_set.rb', line 108 def transmittable? # etc, can go here too end |