Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept every integer type on the #pluralize method #890

Merged
merged 1 commit into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions spec/lucky/text_helpers/pluralize_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ describe Lucky::TextHelpers do
it "pluralizes words" do
view.pluralize(1, "count").should eq "1 count"
view.pluralize(2, "count").should eq "2 counts"
view.pluralize(1000000000000, "count").should eq "1000000000000 counts"
view.pluralize("1", "count").should eq "1 count"
view.pluralize("2", "count").should eq "2 counts"
view.pluralize("1,066", "count").should eq "1,066 counts"
Expand Down
2 changes: 1 addition & 1 deletion src/lucky/page_helpers/text_helpers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ module Lucky::TextHelpers

# It pluralizes `singular` unless `count` is 1. You can specify the `plural` option
# to override the chosen plural word.
def pluralize(count : Int32 | String | Nil, singular : String, plural = nil) : String
def pluralize(count : Int | String | Nil, singular : String, plural = nil) : String
word = if (count == 1 || count =~ /^1(\.0+)?$/)
singular
else
Expand Down