module OptionBinder::Handler
Public Instance Methods
included_in(*a)
click to toggle source
# File lib/optbind/handler.rb, line 10 def included_in(*a) -> (v) { a[0].include? v ? v : raise(OptionParser::InvalidArgument, v) if v } if a[0].is_a? Range -> (v) { a.flatten.include?(v) ? v : raise(OptionParser::InvalidArgument, v) if v } end
Also aliased as: in
listed_as(t)
click to toggle source
# File lib/optbind/handler.rb, line 17 def listed_as(t) -> (v) do begin b, p = nil, OptionParser.new.on(:REQUIRED, '--0', t, &-> (i) { b = i }) (v.is_a?(Array) ? v : v.to_s.split(/,/)).map { |i| p.parse! %W(--0=#{i}) and b } if v rescue OptionParser::InvalidArgument raise $!.tap { |e| e.args[0] = e.args[0].sub(/\A--\d+=/, '') } end end end
Also aliased as: lists
matched_by(p)
click to toggle source
# File lib/optbind/handler.rb, line 4 def matched_by(p) -> (v) { p =~ v.to_s ? v : raise(OptionParser::InvalidArgument, v) if v } end
Also aliased as: matches