Sha256: 98327c6cb7eeb076567f77989452c9a45f8c9b9fd1d5cc89f91ca15ccb961421

Contents?: true

Size: 704 Bytes

Versions: 1

Compression:

Stored size: 704 Bytes

Contents

require 'erb'
require 'ostruct'

module Ru
  class OptionPrinter
    def exists?(option_key)
      ! (options[option_key].nil? || options[option_key].empty?)
    end

    def run(option_key, option_value=nil)
      send(options[option_key], *option_value)
    end

    private

    def options
      {
        help: :get_help,
        version: :get_version
      }
    end

    def get_help
      namespace = OpenStruct.new(version: Ru::VERSION)
      template_path = ::File.expand_path("../../../doc/help.erb", __FILE__)
      template = ::File.open(template_path).read
      ERB.new(template).result(namespace.instance_eval { binding })
    end

    def get_version
      Ru::VERSION
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ru2-2.3.1 lib/ru/option_printer.rb