Class: Ahnnotate::Options
- Inherits:
-
Object
- Object
- Ahnnotate::Options
- Defined in:
- lib/ahnnotate/options.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(**args) ⇒ Options
constructor
A new instance of Options.
- #to_s ⇒ Object
Constructor Details
#initialize(**args) ⇒ Options
Returns a new instance of Options.
26 27 28 29 30 |
# File 'lib/ahnnotate/options.rb', line 26 def initialize(**args) args.each do |key, value| public_send("#{key}=", value) end end |
Class Method Details
.attr_question(*names) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/ahnnotate/options.rb', line 12 def self.attr_question(*names) names.each do |name| attr_writer(name) define_method("#{name}?") do !!instance_variable_get("@#{name}") end end end |
.attr_writer(*names) ⇒ Object
7 8 9 10 |
# File 'lib/ahnnotate/options.rb', line 7 def self.attr_writer(*names) attribute_names.push(*names) super end |
.attribute_names ⇒ Object
3 4 5 |
# File 'lib/ahnnotate/options.rb', line 3 def self.attribute_names @attribute_names ||= [] end |
Instance Method Details
#to_s ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ahnnotate/options.rb', line 32 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 |