#!/usr/bin/env ruby # frozen_string_literal: true lib = File.expand_path(File.dirname(__FILE__) + '/../lib') $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib) require 'turkish_id' @help = ' Usage turkish_id QUERY Examples turkish_id 10000000078 turkish_id 10000000146 ' def parse_input ARGV[0] ? validate_id(ARGV[0]) : print_help end def validate_id(id_number) identity_number = TurkishId.new(id_number) print_result(identity_number.valid?) end def print_result(result) STDOUT.puts "Your identification number is #{result ? 'valid' : 'invalid'}." end def print_help STDOUT.puts @help end parse_input