Skip to content

Commit

Permalink
Doc clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Somto committed Apr 30, 2014
1 parent 2042429 commit 45307ec
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ string manipulation libraries of Java Apache Commons. GoUtils includes the follo
* StringUtils (partial implementation)

## Installation
If you have Go set up on your system, enter this within the command line/terminal:
If you have Go set up on your system, from the GOPATH directory within the command line/terminal, enter this:

go get github.com/aokoli/goutils

Expand Down
16 changes: 8 additions & 8 deletions randomstringutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Parameter:
Returns:
string - the random string
error - an error stemming from an invalid parameter within underlying function
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func RandomNonAlphaNumeric (count int) (string, error) {
return RandomAlphaNumericCustom(count, false, false)
Expand All @@ -54,7 +54,7 @@ Parameter:
Returns:
string - the random string
error - an error stemming from an invalid parameter within underlying function
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func RandomAscii(count int) (string, error) {
return Random(count, 32, 127, false, false)
Expand All @@ -70,7 +70,7 @@ Parameter:
Returns:
string - the random string
error - an error stemming from an invalid parameter within underlying function
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func RandomNumeric (count int) (string, error) {
return Random(count, 0, 0, false, true)
Expand All @@ -88,7 +88,7 @@ Parameters:
Returns:
string - the random string
error - an error stemming from an invalid parameter within underlying function
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func RandomAlphabetic (count int) (string, error) {
return Random(count, 0, 0, true, false)
Expand All @@ -104,7 +104,7 @@ Parameter:
Returns:
string - the random string
error - an error stemming from an invalid parameter within underlying function
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func RandomAlphaNumeric (count int) (string, error) {
return Random(count, 0, 0, true, true)
Expand All @@ -121,7 +121,7 @@ Parameters:
Returns:
string - the random string
error - an error stemming from an invalid parameter within underlying function
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func RandomAlphaNumericCustom (count int, letters bool, numbers bool) (string, error) {
return Random(count, 0, 0, letters, numbers)
Expand All @@ -143,7 +143,7 @@ Parameters:
Returns:
string - the random string
error - an error stemming from invalid parameters: if count < 0; or the provided chars array is empty; or end <= start; or end > len(chars)
error - an error stemming from an invalid parameter within underlying function, RandomSeed(...)
*/
func Random (count int, start int, end int, letters bool, numbers bool, chars ...rune) (string, error) {
return RandomSeed (count, start, end, letters, numbers, chars, RANDOM)
Expand All @@ -154,7 +154,7 @@ func Random (count int, start int, end int, letters bool, numbers bool, chars ..
RandomSeed creates a random string based on a variety of options, using supplied source of randomness.
If the parameters start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used,
unless letters and numbers are both false, in which case, start and end are set to 0 and math.MaxInt32, respectively.
If chars is not nil, characters between start and end are chosen.
If chars is not nil, characters stored in chars that are between start and end are chosen.
This method accepts a user-supplied *rand.Rand instance to use as a source of randomness. By seeding a single *rand.Rand instance
with a fixed seed and using it for each call, the same random sequence of strings can be generated repeatedly and predictably.
Expand Down
10 changes: 10 additions & 0 deletions randomstringutils_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@










package goutils

import (
Expand Down
17 changes: 8 additions & 9 deletions stringutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const INDEX_NOT_FOUND = -1


/*
Abbreviate abbreviates a string using ellipses. This will turn "Now is the time for all good men" into "Now is the time for..."
Abbreviate abbreviates a string using ellipses. This will turn the string "Now is the time for all good men" into "Now is the time for..."
Specifically:
Specifically, the algorithm is as follows:
- If str is less than maxWidth characters long, return it.
- Else abbreviate it to (str[0:maxWidth - 3] + "...").
Expand All @@ -43,29 +43,28 @@ Parameters:
maxWidth - maximum length of result string, must be at least 4
Returns:
string - abbreviated String
string - abbreviated string
error - if the width is too small
*/
func Abbreviate (str string, maxWidth int) (string, error) {
return AbbreviateFull(str, 0, maxWidth)
}


/*
AbbreviateFull abbreviates a string using ellipses. This will turn "Now is the time for all good men" into "...is the time for..."
AbbreviateFull abbreviates a string using ellipses. This will turn the string "Now is the time for all good men" into "...is the time for..."
This function works like Abbreviate(string, int), but allows you to specify a "left edge" offset. Note that this left edge is not
necessarily going to be the leftmost character in the result, or the first character following the ellipses, but it will appear
somewhere in the result.
In no case will it return a String of length greater than maxWidth.
In no case will it return a string of length greater than maxWidth.
Parameters:
str - the String to check
str - the string to check
offset - left edge of source string
maxWidth - maximum length of result string, must be at least 4
Returns:
string - abbreviated String
string - abbreviated string
error - if the width is too small
*/
func AbbreviateFull (str string, offset int, maxWidth int) (string, error) {
Expand Down Expand Up @@ -106,7 +105,7 @@ DeleteWhiteSpace deletes all whitespaces from a string as defined by unicode.IsS
It returns the string without whitespaces.
Parameter:
str - the String to delete whitespace from, may be null
str - the string to delete whitespace from, may be nil
Returns:
the string without whitespaces
Expand Down
4 changes: 3 additions & 1 deletion wordutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ import (
"unicode"
)

// VERSION indicates the current version of goutils
const VERSION = "1.0.0"

/*
Wrap wraps a single line of text, identifying words by ' '.
Expand Down Expand Up @@ -227,7 +229,7 @@ func CapitalizeFully (str string, delimiters ...rune) string {
/*
Uncapitalize uncapitalizes all the whitespace separated words in a string. Only the first letter of each word is changed.
The delimiters represent a set of characters understood to separate words. The first string character and the first non-delimiter
character after a delimiter will be uncapitalized. Whitespace is defined by unicode.IsSpacea(char).
character after a delimiter will be uncapitalized. Whitespace is defined by unicode.IsSpace(char).
Parameters:
str - the string to uncapitalize fully
Expand Down

0 comments on commit 45307ec

Please sign in to comment.