Sha256: f9a91c874d06704c6e51e7898eeab16eab995d55595a787261ace47d7286cdf7
Contents?: true
Size: 1012 Bytes
Versions: 4
Compression:
Stored size: 1012 Bytes
Contents
module Ahnnotate class Options def self.attribute_names @attribute_names ||= [] end def self.attr_writer(*names) attribute_names.push(*names) super end def self.attr_question(*names) names.each do |name| attr_writer(name) define_method("#{name}?") do !!instance_variable_get("@#{name}") end end end attr_question :exit attr_question :fix attr_question :remove def initialize(**args) args.each do |key, value| public_send("#{key}=", value) end end def to_s output = StringIO.new output.puts "🧐 options:" self.class.attribute_names.each do |attribute_name| output.print "🧐 #{attribute_name}: " if instance_variable_defined?("@#{attribute_name}") output.puts "undefined" else output.puts instance_variable_get("@#{attribute_name}").inspect end end output.string end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ahnnotate-0.5.1 | lib/ahnnotate/options.rb |
ahnnotate-0.5.0 | lib/ahnnotate/options.rb |
ahnnotate-0.4.0 | lib/ahnnotate/options.rb |
ahnnotate-0.3.0 | lib/ahnnotate/options.rb |