class TransLaunder::InputParser
Public Class Methods
new(input)
click to toggle source
# File lib/translaunder/input_parser.rb, line 4 def initialize input @input = input end
Public Instance Methods
parse()
click to toggle source
# File lib/translaunder/input_parser.rb, line 8 def parse validate { source_lang: @input.shift.to_sym, target_lang: @input.shift.to_sym, text: @input.join(' ') } end
Private Instance Methods
validate()
click to toggle source
# File lib/translaunder/input_parser.rb, line 20 def validate OutputManager::display_help_and_quit if @input.index('-h') || @input.empty? OutputManager::display_version_and_quit if @input.index("-v") raise ArgumentError if @input.length < 3 @input.first(2).each do |lang| raise ArgumentError unless [2, 4].include? lang.length end rescue ArgumentError OutputManager::display_error_msg end