Class: Msg::Properties::Key
- Inherits:
-
Object
- Object
- Msg::Properties::Key
- Defined in:
- lib/msg/properties.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 ⇒ 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.
457 458 459 |
# File 'lib/msg/properties.rb', line 457 def initialize code, guid=PS_MAPI @code, @guid = code, guid end |
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
456 457 458 |
# File 'lib/msg/properties.rb', line 456 def code @code end |
#guid ⇒ Object (readonly)
Returns the value of attribute guid.
456 457 458 |
# File 'lib/msg/properties.rb', line 456 def guid @guid end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
498 499 500 |
# File 'lib/msg/properties.rb', line 498 def == other hash == other.hash end |
#hash ⇒ Object
this stuff is to allow it to be a useful key
494 495 496 |
# File 'lib/msg/properties.rb', line 494 def hash [code, guid].hash end |
#inspect ⇒ Object
504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
# File 'lib/msg/properties.rb', line 504 def inspect if Integer === code hex = '0x%04x' % code if guid == PS_MAPI # just display as plain hex number hex else "#<Key #{guid}/#{hex}>" end else # display full guid and code "#<Key #{guid}/#{code.inspect}>" end end |
#to_s ⇒ Object
484 485 486 |
# File 'lib/msg/properties.rb', line 484 def to_s to_sym.to_s end |
#to_sym ⇒ Object
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 |
# File 'lib/msg/properties.rb', line 461 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 MAPITAGS['%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
489 490 491 |
# File 'lib/msg/properties.rb', line 489 def transmittable? # etc, can go here too end |