Class: Judges::Options
Overview
Options for Ruby scripts in the judges.
- Author
-
Yegor Bugayenko (yegor256@gmail.com)
- Copyright
-
Copyright © 2024 Yegor Bugayenko
- License
-
MIT
Instance Method Summary collapse
- #+(other) ⇒ Object
-
#initialize(pairs = nil) ⇒ Options
constructor
Ctor.
-
#to_s ⇒ Object
Convert them all to a string (printable in a log).
Constructor Details
#initialize(pairs = nil) ⇒ Options
Ctor.
33 34 35 |
# File 'lib/judges/options.rb', line 33 def initialize(pairs = nil) @pairs = pairs end |
Instance Method Details
#+(other) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/judges/options.rb', line 37 def +(other) touch # this will trigger method_missing() method, which will create @hash h = @hash.dup other.touch # this will trigger method_missing() method, which will create @hash other.instance_variable_get(:@hash).each do |k, v| h[k] = v end Judges::Options.new(h.map { |k, v| "#{k}=#{v}" }) end |
#to_s ⇒ Object
Convert them all to a string (printable in a log).
48 49 50 51 52 53 54 55 |
# File 'lib/judges/options.rb', line 48 def to_s touch # this will trigger method_missing() method, which will create @hash @hash.map do |k, v| v = v.to_s v = "#{v[0..3]}#{'*' * (v.length - 4)}" if v.length > 8 "#{k} → \"#{v}\"" end.join("\n") end |