rufo
rufo copied to clipboard
Support for pattern matching
Hi, I was trying to format some Ruby 3 code where pattern matching is used, and rufo seems not to work with pattern matching. My code(manually formatted and runnable with Ruby 3) and errors are below:
class Value
attr_accessor :full_name, :short_name, :doc
def initialize(info)
case info
in {full_name: f, **}
puts "caught full name"
construct(f)
in {short_name: s, **}
abort "full name must be specifed"
in {full_name: f, short_name: s, **}
puts "caught full name and short name"
construct(f, s)
in {full_name: f, short_name: s, doc: d}
puts "caught full arguments"
construct(f, s, d)
else
abort "only full_name, short_name and doc can be specified"
end
end
def construct(full_name, short_name = nil, doc = nil)
@full_name = full_name
@short_name = short_name
@doc = doc
end
end
Value.new(short_name: "short", doc: "doc")
