Class: JwtCli::InputBuilder
- Inherits:
-
Object
- Object
- JwtCli::InputBuilder
- Includes:
- Thor::Shell
- Defined in:
- lib/jwt_cli/input_builder.rb
Constant Summary collapse
- InvalidEmailError =
Class.new(StandardError)
Instance Method Summary collapse
- #add_additional_information ⇒ Object
- #add_email! ⇒ Object
- #add_user_id ⇒ Object
- #build ⇒ Object
-
#initialize ⇒ InputBuilder
constructor
A new instance of InputBuilder.
Constructor Details
#initialize ⇒ InputBuilder
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_information ⇒ Object
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
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_id ⇒ Object
22 23 24 |
# File 'lib/jwt_cli/input_builder.rb', line 22 def add_user_id @storage[:user_id] = ask 'Enter USER_ID:' end |
#build ⇒ Object
12 13 14 |
# File 'lib/jwt_cli/input_builder.rb', line 12 def build @storage end |