Sha256: 86a8687945b52c2a3850f343279f09a49c6ef12aaf7cbc6ff15c800691d6613d

Contents?: true

Size: 1.99 KB

Versions: 7

Compression:

Stored size: 1.99 KB

Contents

#! /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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
HelloWorldFizzBuzz-1.1.0 lib/HelloWorldFizzBuzz.rb
HelloWorldFizzBuzz-1.0.0 lib/HelloWorldFizzBuzz.rb
HelloWorldFizzBuzz-0.5.0 lib/HelloWorldFizzBuzz.rb
HelloWorldFizzBuzz-0.4.0 lib/HelloWorldFizzBuzz.rb
HelloWorldFizzBuzz-0.3.0 lib/HelloWorldFizzBuzz.rb
HelloWorldFizzBuzz-0.2.0 lib/HelloWorldFizzBuzz.rb
HelloWorldFizzBuzz-0.1.3 lib/HelloWorldFizzBuzz.rb