Class: Keepassx::Group
Instance Attribute Summary collapse
-
#entries ⇒ Object
Returns the value of attribute entries.
-
#parent ⇒ Object
Returns the value of attribute parent.
Attributes inherited from Fieldable
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(payload) ⇒ Group
constructor
A new instance of Group.
-
#level ⇒ Object
Redefine #level method to return 0 instead of nil.
Methods inherited from Fieldable
create_fieldable_methods, #encode, fields, #inspect, #length, set_field_descriptor, #to_hash
Constructor Details
#initialize(payload) ⇒ Group
Returns a new instance of Group.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/keepassx/group.rb', line 34 def initialize(payload) @parent = nil @entries = [] super do # Do some validation raise ArgumentError, "'id' is required (type: integer)" unless valid_integer?(payload[:id]) raise ArgumentError, "'name' is required (type: string)" unless valid_string?(payload[:name]) # First set @parent and @level. # Remove key from payload to not interfere with KeePassX fields format self.parent = payload.delete(:parent) # Build list of fields @fields = build_payload(payload) end end |
Instance Attribute Details
#entries ⇒ Object
Returns the value of attribute entries.
31 32 33 |
# File 'lib/keepassx/group.rb', line 31 def entries @entries end |
#parent ⇒ Object
Returns the value of attribute parent.
32 33 34 |
# File 'lib/keepassx/group.rb', line 32 def parent @parent end |
Class Method Details
Instance Method Details
#==(other) ⇒ Object
86 87 88 89 90 91 92 93 94 |
# File 'lib/keepassx/group.rb', line 86 def ==(other) return false if other.nil? parent == other.parent && name == other.name && id == other.id && level == other.level && icon == other.icon end |
#level ⇒ Object
Redefine #level method to return 0 instead of nil
80 81 82 83 |
# File 'lib/keepassx/group.rb', line 80 def level value = get :level value.nil? ? 0 : value end |