Class: Mapi::PropertySet::Key
- Inherits:
-
Object
- Object
- Mapi::PropertySet::Key
- Includes:
- Constants
- Defined in:
- lib/mapi/property_set.rb
Overview
Properties
are accessed by Key
s, 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 ⇒ Object
readonly
Returns the value of attribute code.
-
#guid ⇒ Object
readonly
Returns the value of attribute guid.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#hash ⇒ Object
this stuff is to allow it to be a useful key.
-
#initialize(code, guid = PS_MAPI) ⇒ Key
constructor
A new instance of Key.
- #inspect ⇒ Object
- #to_s ⇒ Object
- #to_sym ⇒ Object
-
#transmittable? ⇒ Boolean
FIXME implement these.
Constructor Details
#initialize(code, guid = PS_MAPI) ⇒ Key
Returns a new instance of Key.
68 69 70 |
# File 'lib/mapi/property_set.rb', line 68 def initialize code, guid=PS_MAPI @code, @guid = code, guid end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
67 68 69 |
# File 'lib/mapi/property_set.rb', line 67 def code @code end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
67 68 69 |
# File 'lib/mapi/property_set.rb', line 67 def guid @guid end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
109 110 111 |
# File 'lib/mapi/property_set.rb', line 109 def == other hash == other.hash end |
#hash ⇒ Object
this stuff is to allow it to be a useful key
105 106 107 |
# File 'lib/mapi/property_set.rb', line 105 def hash [code, guid].hash end |
#inspect ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/mapi/property_set.rb', line 115 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 ⇒ Object
95 96 97 |
# File 'lib/mapi/property_set.rb', line 95 def to_s to_sym.to_s end |
#to_sym ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mapi/property_set.rb', line 72 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
100 101 102 |
# File 'lib/mapi/property_set.rb', line 100 def transmittable? # etc, can go here too end |