Class: Donjon::User

Inherits:
Object
  • Object
show all
Extended by:
ClassMethods, SharedMethods
Includes:
SharedMethods
Defined in:
lib/donjon/user.rb

Defined Under Namespace

Modules: ClassMethods, SharedMethods

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ClassMethods

each, find

Constructor Details

#initialize(name:, key:, repo:) ⇒ User

Returns a new instance of User.



8
9
10
11
12
13
14
# File 'lib/donjon/user.rb', line 8

def initialize(name:, key:, repo:)
  assert(key.n.num_bits == 2048)
  
  @name  = name
  @key   = key
  @repo  = repo
end

Instance Attribute Details

#keyObject (readonly)

Returns the value of attribute key.



6
7
8
# File 'lib/donjon/user.rb', line 6

def key
  @key
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/donjon/user.rb', line 6

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo.



6
7
8
# File 'lib/donjon/user.rb', line 6

def repo
  @repo
end

Instance Method Details

#saveObject



16
17
18
19
20
21
22
# File 'lib/donjon/user.rb', line 16

def save
  _path_for(@name, @repo).tap do |path|
    path.parent.mkpath
    path.write @key.public_key.to_pem
  end
  self
end