class Toys::FlagGroup::Base
The base class of a FlagGroup
, implementing everything except validation. The base class effectively behaves as an Optional
group. And the default group that contains flags not otherwise assigned to a group, is of this type. However, you should use {Toys::FlagGroup::Optional} when creating an explicit optional group.
Attributes
The short description string.
When reading, this is always returned as a {Toys::WrappableString}.
When setting, the description may be provided as any of the following:
* A {Toys::WrappableString}. * A normal String, which will be transformed into a {Toys::WrappableString} using spaces as word delimiters. * An Array of String, which will be transformed into a {Toys::WrappableString} where each array element represents an individual word for wrapping.
@return [Toys::WrappableString]
An array of flags that are in this group. Do not modify the returned array. @return [Array<Toys::Flag>]
The long description strings.
When reading, this is returned as an Array of {Toys::WrappableString} representing the lines in the description.
When setting, the description must be provided as an Array where *each element* may be any of the following:
* A {Toys::WrappableString} representing one line. * A normal String representing a line. This will be transformed into a {Toys::WrappableString} using spaces as word delimiters. * An Array of String representing a line. This will be transformed into a {Toys::WrappableString} where each array element represents an individual word for wrapping.
@return [Array<Toys::WrappableString>]
The symbolic name for this group @return [String,Symbol,nil]
Public Class Methods
Create a flag group. This argument list is subject to change. Use {Toys::FlagGroup.create} instead for a more stable interface. @private
# File lib/toys/flag_group.rb, line 61 def initialize(name, desc, long_desc) @name = name @desc = WrappableString.make(desc) @long_desc = WrappableString.make_array(long_desc) @flags = [] end
Public Instance Methods
@private
# File lib/toys/flag_group.rb, line 172 def <<(flag) flags << flag end
Append long description strings.
You must pass an array of lines in the long description. See {#long_desc} for details on how each line may be represented.
@param long_desc
[Array<Toys::WrappableString,String,Array<String>>] @return [self]
# File lib/toys/flag_group.rb, line 166 def append_long_desc(long_desc) @long_desc.concat(WrappableString.make_array(long_desc)) self end
Set the short description string.
See {#desc} for details.
@param desc [Toys::WrappableString,String,Array<String>]
# File lib/toys/flag_group.rb, line 142 def desc=(desc) @desc = WrappableString.make(desc) end
Returns true if this group is empty @return [Boolean]
# File lib/toys/flag_group.rb, line 121 def empty? flags.empty? end
Set the long description strings.
See {#long_desc} for details.
@param long_desc
[Array<Toys::WrappableString,String,Array<String>>]
# File lib/toys/flag_group.rb, line 153 def long_desc=(long_desc) @long_desc = WrappableString.make_array(long_desc) end
Returns a string summarizing this group. This is generally either the short description or a representation of all the flags included. @return [String]
# File lib/toys/flag_group.rb, line 130 def summary return desc.to_s.inspect unless desc.empty? flags.map(&:display_name).inspect end
@private
# File lib/toys/flag_group.rb, line 177 def validation_errors(_seen) [] end