| 1 |
INSTALLATION |
| 2 |
|
| 3 |
go get bitbucket.org/pkg/inflect |
| 4 |
|
| 5 |
PACKAGE |
| 6 |
|
| 7 |
package inflect |
| 8 |
|
| 9 |
|
| 10 |
FUNCTIONS |
| 11 |
|
| 12 |
func AddAcronym(word string) |
| 13 |
|
| 14 |
func AddHuman(suffix, replacement string) |
| 15 |
|
| 16 |
func AddIrregular(singular, plural string) |
| 17 |
|
| 18 |
func AddPlural(suffix, replacement string) |
| 19 |
|
| 20 |
func AddSingular(suffix, replacement string) |
| 21 |
|
| 22 |
func AddUncountable(word string) |
| 23 |
|
| 24 |
func Asciify(word string) string |
| 25 |
|
| 26 |
func Camelize(word string) string |
| 27 |
|
| 28 |
func CamelizeDownFirst(word string) string |
| 29 |
|
| 30 |
func Capitalize(word string) string |
| 31 |
|
| 32 |
func Dasherize(word string) string |
| 33 |
|
| 34 |
func ForeignKey(word string) string |
| 35 |
|
| 36 |
func ForeignKeyCondensed(word string) string |
| 37 |
|
| 38 |
func Humanize(word string) string |
| 39 |
|
| 40 |
func Ordinalize(word string) string |
| 41 |
|
| 42 |
func Parameterize(word string) string |
| 43 |
|
| 44 |
func ParameterizeJoin(word, sep string) string |
| 45 |
|
| 46 |
func Pluralize(word string) string |
| 47 |
|
| 48 |
func Singularize(word string) string |
| 49 |
|
| 50 |
func Tableize(word string) string |
| 51 |
|
| 52 |
func Titleize(word string) string |
| 53 |
|
| 54 |
func Typeify(word string) string |
| 55 |
|
| 56 |
func Uncountables() map[string]bool |
| 57 |
|
| 58 |
func Underscore(word string) string |
| 59 |
|
| 60 |
|
| 61 |
TYPES |
| 62 |
|
| 63 |
type Rule struct { |
| 64 |
// contains filtered or unexported fields |
| 65 |
} |
| 66 |
used by rulesets |
| 67 |
|
| 68 |
type Ruleset struct { |
| 69 |
// contains filtered or unexported fields |
| 70 |
} |
| 71 |
a Ruleset is the config of pluralization rules |
| 72 |
you can extend the rules with the Add* methods |
| 73 |
|
| 74 |
func NewDefaultRuleset() *Ruleset |
| 75 |
create a new ruleset and load it with the default |
| 76 |
set of common English pluralization rules |
| 77 |
|
| 78 |
func NewRuleset() *Ruleset |
| 79 |
create a blank ruleset. Unless you are going to |
| 80 |
build your own rules from scratch you probably |
| 81 |
won't need this and can just use the defaultRuleset |
| 82 |
via the global inflect.* methods |
| 83 |
|
| 84 |
func (rs *Ruleset) AddAcronym(word string) |
| 85 |
if you use acronym you may need to add them to the ruleset |
| 86 |
to prevent Underscored words of things like "HTML" coming out |
| 87 |
as "h_t_m_l" |
| 88 |
|
| 89 |
func (rs *Ruleset) AddHuman(suffix, replacement string) |
| 90 |
Human rules are applied by humanize to show more friendly |
| 91 |
versions of words |
| 92 |
|
| 93 |
func (rs *Ruleset) AddIrregular(singular, plural string) |
| 94 |
Add any inconsistant pluralizing/sinularizing rules |
| 95 |
to the set here. |
| 96 |
|
| 97 |
func (rs *Ruleset) AddPlural(suffix, replacement string) |
| 98 |
add a pluralization rule |
| 99 |
|
| 100 |
func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool) |
| 101 |
add a pluralization rule with full string match |
| 102 |
|
| 103 |
func (rs *Ruleset) AddSingular(suffix, replacement string) |
| 104 |
add a singular rule |
| 105 |
|
| 106 |
func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool) |
| 107 |
same as AddSingular but you can set `exact` to force |
| 108 |
a full string match |
| 109 |
|
| 110 |
func (rs *Ruleset) AddUncountable(word string) |
| 111 |
add a word to this ruleset that has the same singular and plural form |
| 112 |
for example: "rice" |
| 113 |
|
| 114 |
func (rs *Ruleset) Asciify(word string) string |
| 115 |
transforms latin characters like é -> e |
| 116 |
|
| 117 |
func (rs *Ruleset) Camelize(word string) string |
| 118 |
"dino_party" -> "DinoParty" |
| 119 |
|
| 120 |
func (rs *Ruleset) CamelizeDownFirst(word string) string |
| 121 |
same as Camelcase but with first letter downcased |
| 122 |
|
| 123 |
func (rs *Ruleset) Capitalize(word string) string |
| 124 |
uppercase first character |
| 125 |
|
| 126 |
func (rs *Ruleset) Dasherize(word string) string |
| 127 |
"SomeText" -> "some-text" |
| 128 |
|
| 129 |
func (rs *Ruleset) ForeignKey(word string) string |
| 130 |
an underscored foreign key name "Person" -> "person_id" |
| 131 |
|
| 132 |
func (rs *Ruleset) ForeignKeyCondensed(word string) string |
| 133 |
a foreign key (with an underscore) "Person" -> "personid" |
| 134 |
|
| 135 |
func (rs *Ruleset) Humanize(word string) string |
| 136 |
First letter of sentance captitilized |
| 137 |
Uses custom friendly replacements via AddHuman() |
| 138 |
|
| 139 |
func (rs *Ruleset) Ordinalize(str string) string |
| 140 |
"1031" -> "1031st" |
| 141 |
|
| 142 |
func (rs *Ruleset) Parameterize(word string) string |
| 143 |
param safe dasherized names like "my-param" |
| 144 |
|
| 145 |
func (rs *Ruleset) ParameterizeJoin(word, sep string) string |
| 146 |
param safe dasherized names with custom seperator |
| 147 |
|
| 148 |
func (rs *Ruleset) Pluralize(word string) string |
| 149 |
returns the plural form of a singular word |
| 150 |
|
| 151 |
func (rs *Ruleset) Singularize(word string) string |
| 152 |
returns the singular form of a plural word |
| 153 |
|
| 154 |
func (rs *Ruleset) Tableize(word string) string |
| 155 |
Rails style pluralized table names: "SuperPerson" -> "super_people" |
| 156 |
|
| 157 |
func (rs *Ruleset) Titleize(word string) string |
| 158 |
Captitilize every word in sentance "hello there" -> "Hello There" |
| 159 |
|
| 160 |
func (rs *Ruleset) Typeify(word string) string |
| 161 |
"something_like_this" -> "SomethingLikeThis" |
| 162 |
|
| 163 |
func (rs *Ruleset) Uncountables() map[string]bool |
| 164 |
|
| 165 |
func (rs *Ruleset) Underscore(word string) string |
| 166 |
lowercase underscore version "BigBen" -> "big_ben" |
| 167 |
|
| 168 |
|