Documentation ¶
Index ¶
- type String
- func (s *String) AppendRune(r rune)
- func (s *String) AppendString(otherS string)
- func (s *String) Copy() com.Copier
- func (s *String) Equals(other com.Equaler) bool
- func (s *String) Fields() []*String
- func (s *String) GetContent() string
- func (s *String) GetLength() int
- func (s *String) PrependRune(r rune)
- func (s *String) PrependString(otherS string)
- func (s *String) ReplaceSuffix(suffix string) bool
- func (s *String) Runes(width, height int) ([][]rune, error)
- func (s *String) String() string
- func (s *String) TrimEnd(limit int) *String
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type String ¶
type String struct {
// contains filtered or unexported fields
}
String represents a unit of data in a draw table with a specific style.
func FieldsFunc ¶
FieldsFunc splits a string into fields using a function to determine the separator.
Parameters:
- s: The string to split.
- sep: The function to determine the separator.
Returns:
- []*String: The fields of the string.
func Join ¶
Join joins a slice of strings with a separator.
Parameters:
- elems: The slice of strings to join.
- sep: The separator to join the strings with.
Returns:
- *String: The joined string.
Behaviors:
- If the slice of strings is empty, a nil string is returned.
- The style of the first string is used for the joined string.
- The separator is not added to the end of the joined string.
func NewString ¶
NewDtUnit creates a new DtUnit with the given content and style.
Parameters:
- content: The content of the unit.
Returns:
- *DtUnit: The new DtUnit.
func Repeat ¶
Repeat repeats a string count times.
Parameters:
- s: The string to repeat.
- count: The number of times to repeat the string.
Returns:
- *String: The repeated string.
Behaviors:
- If the count is less than or equal to 0, nil is returned.
func (*String) AppendRune ¶
AppendRune appends a rune to the content of the unit.
Parameters:
- r: The rune to append.
func (*String) AppendString ¶
AppendString appends a string to the content of the unit.
Parameters:
- otherS: The string to append.
func (*String) Fields ¶
Fields splits a string into fields.
Returns:
- []*String: The fields of the string.
func (*String) GetContent ¶
GetContent returns the content of the unit.
Returns:
- string: The content of the unit.
func (*String) GetLength ¶
GetLength returns the length of the content.
Returns:
- int: The length of the content.
func (*String) PrependRune ¶
PrependRune prepends a rune to the content of the unit.
Parameters:
- r: The rune to prepend.
func (*String) PrependString ¶
PrependString prepends a string to the content of the unit.
Parameters:
- otherS: The string to prepend.
func (*String) ReplaceSuffix ¶
ReplaceSuffix replaces the end of the string with the given suffix. It fails if the suffix is longer than the string.
Parameters:
- suffix: The suffix to replace the end of the string.
Returns:
- bool: True if the suffix was replaced, and false otherwise.
func (*String) Runes ¶
Runes returns the content of the unit as a slice of runes.
Parameters:
- width: The width of the table.
- height: The height of the table.
Returns:
- [][]rune: The content of the unit as a slice of runes.
- error: An error if the content could not be converted to runes.
Behaviors:
- Always assume that the width and height are greater than 0. No need to check for this.
- Never errors.
func (*String) String ¶
String returns the content of the unit as a string.
Returns:
- string: The content of the unit.
func (*String) TrimEnd ¶
TrimEnd trims the end of the string to the given limit.
Parameters:
- limit: The limit to trim the string to.
Returns:
- *String: The trimmed string.
Behaviors:
- If the limit is less than or equal to 0, the string is set to an empty string.
- If the limit is greater than the length of the string, the string is unchanged.