Sha256: 7d6b022a7c9afe4dc4b755377ed0c5ee0d066b3f4436157b655da4e97bfd284c
Contents?: true
Size: 980 Bytes
Versions: 3
Compression:
Stored size: 980 Bytes
Contents
require 'erb' require 'ostruct' module Ru class OptionPrinter attr_accessor :options_parser def initialize(options_parser: nil) @options_parser = options_parser end def exists?(option_key) !options[option_key].to_s.empty? end def run(option_key, option_value=nil) send(options[option_key], *option_value) end private def options { h: :get_usage, help: :get_help, version: :get_version } end def get_usage options_parser.to_s 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 result = get_usage result.concat "\n" result.concat ERB.new(template).result(namespace.instance_eval { binding }) result end def get_version Ru::VERSION end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ru2-2.6.0 | lib/ru/option_printer.rb |
ru2-2.5.0 | lib/ru/option_printer.rb |
ru2-2.4.0 | lib/ru/option_printer.rb |