Class: SafeEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/safeentry.rb

Overview

SafeEntry A single entry (name, ID, password) in the “safe”

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, id, password) ⇒ SafeEntry

Returns a new instance of SafeEntry.



42
43
44
45
46
# File 'lib/safeentry.rb', line 42

def initialize(name, id, password)
  self.name = name
  self.id = id
  self.password = password
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



40
41
42
# File 'lib/safeentry.rb', line 40

def id
  @id
end

#nameObject

Returns the value of attribute name.



40
41
42
# File 'lib/safeentry.rb', line 40

def name
  @name
end

#passwordObject

Returns the value of attribute password.



40
41
42
# File 'lib/safeentry.rb', line 40

def password
  @password
end

Instance Method Details

#<=>(other) ⇒ Object



52
53
54
# File 'lib/safeentry.rb', line 52

def <=>(other)
  self.name.upcase <=> other.name.upcase
end

#equals?(other) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
59
60
61
62
# File 'lib/safeentry.rb', line 56

def equals? other
  if other == nil
    false
  else
    self.name == other.name && self.id == other.id && self.password == other.password
  end
end

#to_sObject



48
49
50
# File 'lib/safeentry.rb', line 48

def to_s
  "#@name\t#@id\t#@password"
end