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

New feature: string pad #226

Open
TheoryOfNekomata opened this issue Oct 26, 2016 · 2 comments
Open

New feature: string pad #226

TheoryOfNekomata opened this issue Oct 26, 2016 · 2 comments

Comments

@TheoryOfNekomata
Copy link

Self-explanatory. But instead of the default left and right pad filters, there's a center pad.

@adccb
Copy link
Contributor

adccb commented Dec 13, 2016

i'll take a crack at this. @Temoto-kun, how were you envisioning this working? for a one-directional pad, we can just say "take this string and put zeros at the end until the total length is 10." there's not such a clear path on a center-pad. would you specify a total length and then pad either side until it matched? would you specify a number of characters to be appended to both sides? how would you deal with cases where you'd wind up with an uneven number of pad characters?

probably i would be inclined to specify a target string length and pad either side progressively until we reach it. if we hit length and there's an uneven number of pad characters, it'll knock one off the too-long side. this could result in a string being shorter than specified, but i think it'll preserve aesthetic appeal.

@TheoryOfNekomata
Copy link
Author

if we hit length and there's an uneven number of pad characters, it'll knock one off the too-long side.

Or it can have the option of bias, whether to allow more pad characters to the left or right. In that case, I'm thinking it could have separate filters for the one-directional and the bi-directional pad so as not to put too many args on a single pad function. You could dismiss that notion, but I'm just giving a suggestion on how it should be implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants