Class: JwtCli::InputBuilder

Inherits:
Object
  • Object
show all
Includes:
Thor::Shell
Defined in:
lib/jwt_cli/input_builder.rb

Constant Summary collapse

InvalidEmailError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initializeInputBuilder

Returns a new instance of InputBuilder.



8
9
10
# File 'lib/jwt_cli/input_builder.rb', line 8

def initialize
  @storage = {}
end

Instance Method Details

#add_additional_informationObject



26
27
28
29
30
31
32
33
# File 'lib/jwt_cli/input_builder.rb', line 26

def add_additional_information
  key = ask 'Enter key:'
  if @storage.key?(key)
    say "You have already enetered key #{key}. Please choose another one."
  else
    @storage[key] = ask "Enter value for #{key}:"
  end
end

#add_email!Object

Raises:



16
17
18
19
20
# File 'lib/jwt_cli/input_builder.rb', line 16

def add_email!
  email = ask 'Enter EMAIL:'
  raise InvalidEmailError, 'Email format is invalid!' unless email_valid?(email)
  @storage[:email] = email
end

#add_user_idObject



22
23
24
# File 'lib/jwt_cli/input_builder.rb', line 22

def add_user_id
  @storage[:user_id] = ask 'Enter USER_ID:'
end

#buildObject



12
13
14
# File 'lib/jwt_cli/input_builder.rb', line 12

def build
  @storage
end