Class: Keepassx::GroupField
- Inherits:
-
Object
- Object
- Keepassx::GroupField
- Defined in:
- lib/keepassx/group_field.rb
Constant Summary collapse
- FIELD_TYPES =
[ [0x0, 'ignored', :null], [0x1, 'groupid', :int], [0x2, 'group_name', :string], [0x3, 'creation_time', :date], [0x4, 'lastmod_time', :date], [0x5, 'lastacc_time', :date], [0x6, 'expire_time', :date], [0x7, 'imageid', :int], [0x8, 'level', :short], [0x9, 'flags', :int], [0xFFFF, 'terminator', :null] ]
- FIELD_TERMINATOR =
0xFFFF
- TYPE_CODE_FIELD_SIZE =
unsigned short integer
2
- DATA_LENGTH_FIELD_SIZE =
unsigned integer
4
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#data_type ⇒ Object
readonly
Returns the value of attribute data_type.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #_parse_type_code(type_code) ⇒ Object
-
#initialize(payload) ⇒ GroupField
constructor
A new instance of GroupField.
- #length ⇒ Object
- #terminator? ⇒ Boolean
Constructor Details
#initialize(payload) ⇒ GroupField
Returns a new instance of GroupField.
23 24 25 26 27 |
# File 'lib/keepassx/group_field.rb', line 23 def initialize(payload) type_code, @data_length = payload.read(TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE).unpack('SI') @name, @data_type = _parse_type_code(type_code) @data = payload.read(@data_length) end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
21 22 23 |
# File 'lib/keepassx/group_field.rb', line 21 def data @data end |
#data_type ⇒ Object (readonly)
Returns the value of attribute data_type.
21 22 23 |
# File 'lib/keepassx/group_field.rb', line 21 def data_type @data_type end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/keepassx/group_field.rb', line 21 def name @name end |
Instance Method Details
#_parse_type_code(type_code) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/keepassx/group_field.rb', line 37 def _parse_type_code(type_code) (_, name, data_type) = FIELD_TYPES.detect do |(code, *rest)| code == type_code end [name, data_type] end |
#length ⇒ Object
33 34 35 |
# File 'lib/keepassx/group_field.rb', line 33 def length TYPE_CODE_FIELD_SIZE + DATA_LENGTH_FIELD_SIZE + @data_length end |
#terminator? ⇒ Boolean
29 30 31 |
# File 'lib/keepassx/group_field.rb', line 29 def terminator? name == 'terminator' end |