#! /bin/usr/env ruby require File.join(File.dirname(__FILE__), 'HelloWorldFizzBuzz/trollop.rb') require File.join(File.dirname(__FILE__), 'HelloWorldFizzBuzz/version.rb') require File.join(File.dirname(__FILE__), 'HelloWorldFizzBuzz/sqlite.rb') require 'sequel' # HelloWorldFizzBuzz module HelloWorldFizzBuzz # Program class Program include HelloWorldFizzBuzz::Sqlite def initialize connect_database startmenu options end def startmenu @opts = Trollop.options do opt :helloworld, 'creates a helloworld example', short: 'w', type: :string opt :fizzbuzz, 'creates a fizzbuzz example', short: 'b', type: :string opt :license, 'show license of HelloWorldFizzBuzz' end end def options if @opts[:helloworld] hello_world elsif @opts[:fizzbuzz] fizz_buzz elsif @opts[:license] license end end def hello_world(hw = @opts[:helloworld].to_s) select_language = @posts.where[language: hw] if select_language.nil? print 'Unknown programming language please try again ' elsif puts select_language.fetch(:helloworld) end end def fizz_buzz(fb = @opts[:fizzbuzz].to_s) select_language = @posts.where[language: fb] if select_language.nil? print 'Unknown programming language please try again ' elsif puts select_language.fetch(:fizzbuzz) end end def license print " HelloWorldFizzBuzz - A commandline app to show examples of hello world & fizzbuzz in different programming languages Copyright (C) 2016 Derek Viera This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. " end end Program.new end