Class: TalcOTP

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

Instance Method Summary collapse

Constructor Details

#initialize(file) ⇒ TalcOTP

Returns a new instance of TalcOTP.



5
6
7
8
9
10
11
12
13
# File 'lib/talcotp.rb', line 5

def initialize file
  file = File.file?(file) ? File.read(file) : ''

  begin
    @accounts = JSON.parse(file)
  rescue JSON::ParserError
    @accounts = {}
  end
end

Instance Method Details

#[](account_name) ⇒ Object



26
27
28
29
# File 'lib/talcotp.rb', line 26

def []()
   = @accounts.find { || ["label"] ==  }
  return auth_code()
end

#all_codes_stringObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/talcotp.rb', line 15

def all_codes_string
  output = ''
  @accounts.each do ||
     = auth_code()

    output += "#{['label']}: #{}\n"
  end

  output
end