Sha256: eb000154989546f0582ffe20bbf27066e46e490c4ff16a87e4c88cbc492acd56
Contents?: true
Size: 804 Bytes
Versions: 28
Compression:
Stored size: 804 Bytes
Contents
require 'cl/cast' class Cl class Arg < Struct.new(:name, :opts) include Cast def define(const) const.send(:attr_accessor, name) end def set(cmd, value) cmd.send(:"#{name}=", cast(value)) end def type opts[:type] || :string end def description opts[:description] end def required? !!opts[:required] end def separator opts[:sep] end def splat? opts[:splat] && type == :array end def to_s str = name case type when :array then str = "#{str}.." when :boolean, :bool then str = "#{str}:bool" when :integer, :int then str = "#{str}:int" when :float then str = "#{str}:float" end required? ? str : "[#{str}]" end end end
Version data entries
28 entries across 28 versions & 1 rubygems