class HelloWorldFizzBuzz::Program

Program

Public Class Methods

new() click to toggle source
# File lib/HelloWorldFizzBuzz.rb, line 14
def initialize
  connect_database
  startmenu
  options
end

Public Instance Methods

fizz_buzz(fb = @opts[:fizzbuzz].to_s) click to toggle source
# File lib/HelloWorldFizzBuzz.rb, line 49
    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
hello_world(hw = @opts[:helloworld].to_s) click to toggle source
# File lib/HelloWorldFizzBuzz.rb, line 40
    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
license() click to toggle source
# File lib/HelloWorldFizzBuzz.rb, line 58
    def license
      print 'MIT License

Copyright (c) 2016 Derek Viera

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
'
    end
options() click to toggle source
# File lib/HelloWorldFizzBuzz.rb, line 30
def options
  if @opts[:helloworld]
    hello_world
  elsif @opts[:fizzbuzz]
    fizz_buzz
  elsif @opts[:license]
    license
  end
end
startmenu() click to toggle source
# File lib/HelloWorldFizzBuzz.rb, line 20
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