Class: Palm::Record
- Inherits:
-
Object
- Object
- Palm::Record
- Defined in:
- lib/palm/palm_record.rb
Overview
Base class for all Palm::PDB Records. This stores the basic metadata for each record. Subclasses should extend this provide a useful interface for accessing specific record types.
Direct Known Subclasses
Constant Summary collapse
- RECORD_ATTRIBUTE_CODES =
{ :expunged => 0x80, :dirty => 0x40, :deleted => 0x20, :private => 0x10 }
Instance Attribute Summary collapse
-
#archive ⇒ Object
Returns the value of attribute archive.
-
#category ⇒ Object
Returns the value of attribute category.
-
#deleted ⇒ Object
Returns the value of attribute deleted.
-
#dirty ⇒ Object
Returns the value of attribute dirty.
-
#expunged ⇒ Object
Returns the value of attribute expunged.
-
#private ⇒ Object
Returns the value of attribute private.
-
#record_id ⇒ Object
Returns the value of attribute record_id.
Instance Method Summary collapse
-
#initialize ⇒ Record
constructor
A new instance of Record.
- #packed_attributes ⇒ Object
- #packed_attributes=(value) ⇒ Object
Constructor Details
#initialize ⇒ Record
Returns a new instance of Record.
16 17 18 19 20 |
# File 'lib/palm/palm_record.rb', line 16 def initialize @category = 0 @record_id = 0 @dirty = true end |
Instance Attribute Details
#archive ⇒ Object
Returns the value of attribute archive.
13 14 15 |
# File 'lib/palm/palm_record.rb', line 13 def archive @archive end |
#category ⇒ Object
Returns the value of attribute category.
14 15 16 |
# File 'lib/palm/palm_record.rb', line 14 def category @category end |
#deleted ⇒ Object
Returns the value of attribute deleted.
13 14 15 |
# File 'lib/palm/palm_record.rb', line 13 def deleted @deleted end |
#dirty ⇒ Object
Returns the value of attribute dirty.
13 14 15 |
# File 'lib/palm/palm_record.rb', line 13 def dirty @dirty end |
#expunged ⇒ Object
Returns the value of attribute expunged.
13 14 15 |
# File 'lib/palm/palm_record.rb', line 13 def expunged @expunged end |
#private ⇒ Object
Returns the value of attribute private.
13 14 15 |
# File 'lib/palm/palm_record.rb', line 13 def private @private end |
#record_id ⇒ Object
Returns the value of attribute record_id.
14 15 16 |
# File 'lib/palm/palm_record.rb', line 14 def record_id @record_id end |
Instance Method Details
#packed_attributes ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/palm/palm_record.rb', line 22 def packed_attributes encoded = 0 if @expunged or @deleted encoded |= 0x08 if @archive else encoded = @category & 0x0f end RECORD_ATTRIBUTE_CODES.each do |name,code| encoded |= code if send(name) end encoded end |
#packed_attributes=(value) ⇒ Object
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/palm/palm_record.rb', line 37 def packed_attributes=(value) RECORD_ATTRIBUTE_CODES.each do |key,code| self.send("#{key}=", (value & code) > 0) end if (value & 0xa0) == 0 @category = (value & 0x0f) else @archive = (value & 0x08) > 0 end end |