Class: OsCtld::SendReceive::KeyChain::Key

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/send_receive/key_chain.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, pubkey, opts = {}) ⇒ Key

Returns a new instance of Key.



22
23
24
25
26
27
28
29
30
# File 'lib/osctld/send_receive/key_chain.rb', line 22

def initialize(name, pubkey, opts = {})
  @name = name
  @pubkey = pubkey
  @from = opts[:from] && opts[:from].split(',')
  @ctid = opts[:ctid]
  @passphrase = opts[:passphrase]
  @single_use = opts[:single_use]
  @in_use = opts[:in_use] || false
end

Instance Attribute Details

#ctidObject (readonly)

Returns the value of attribute ctid.



19
20
21
# File 'lib/osctld/send_receive/key_chain.rb', line 19

def ctid
  @ctid
end

#fromObject (readonly)

Returns the value of attribute from.



19
20
21
# File 'lib/osctld/send_receive/key_chain.rb', line 19

def from
  @from
end

#in_useObject

Returns the value of attribute in_use.



20
21
22
# File 'lib/osctld/send_receive/key_chain.rb', line 20

def in_use
  @in_use
end

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/osctld/send_receive/key_chain.rb', line 19

def name
  @name
end

#passphraseObject (readonly)

Returns the value of attribute passphrase.



19
20
21
# File 'lib/osctld/send_receive/key_chain.rb', line 19

def passphrase
  @passphrase
end

#pubkeyObject (readonly)

Returns the value of attribute pubkey.



19
20
21
# File 'lib/osctld/send_receive/key_chain.rb', line 19

def pubkey
  @pubkey
end

#single_useObject (readonly)

Returns the value of attribute single_use.



19
20
21
# File 'lib/osctld/send_receive/key_chain.rb', line 19

def single_use
  @single_use
end

Class Method Details

.load(hash) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/osctld/send_receive/key_chain.rb', line 7

def self.load(hash)
  new(
    hash['name'],
    hash['pubkey'],
    from: hash['from'],
    ctid: hash['ctid'],
    passphrase: hash['passphrase'],
    single_use: hash['single_use'],
    in_use: hash['in_use']
  )
end

Instance Method Details

#dumpObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/osctld/send_receive/key_chain.rb', line 40

def dump
  {
    'name' => name,
    'pubkey' => pubkey,
    'from' => from && from.join(','),
    'ctid' => ctid,
    'passphrase' => passphrase,
    'single_use' => single_use,
    'in_use' => in_use
  }
end

#in_use?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/osctld/send_receive/key_chain.rb', line 36

def in_use?
  in_use
end

#single_use?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/osctld/send_receive/key_chain.rb', line 32

def single_use?
  single_use
end