Sha256: 3feebd27feec1a7d335104d04b0f76179541b473774ce0fd8daa9b6911d77a8e

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

# Render::Text::Helper

This gem extends text manipulation to classes like String, Boolean etc..

## Installation

Install the gem and add to the application's Gemfile by executing:

    $ bundle add render-text-helper

If bundler is not being used to manage dependencies, install the gem by executing:

    $ gem install render-text-helper

## Usage

### Limit Print

This function makes sure that the string does not go over a specific given limit.
It has two parameters "limit" which is defaulted to 32 and "more_indicator" which
defaults to "."

```ruby
'hello'.limit_print
'hello'

'elephant'.limit_print(limit: 2)
'el...'

'elephant'.limit_print(limit: 2, more_indicator: '')
'el'

'elephant'.limit_print(limit: 3, more_indicator: '_')
'ele___'
```

### to yes no

This function returns a string from a boolean to yes or no.
It takes in optional casting parameter which can be either capitalize, upcase, or downcase.

```ruby
true.to_yes_no
'Yes'

true.to_yes_no(:upcase)
'YES'

false.to_yes_no(:downcase)
'no'

false.to_yes_no
false.to_yes_no(:capitalize)
'No'
```

### to yn

This function returns a string from a boolean to Y or N

```ruby
true.to_yn
'Y'

true.to_yn(capital_letter: false)
'y'

false.to_yn
'N'

false.to_yn(capital_letter: false)
'n'
```

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/SaimonL/render-text-helper

## License

The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
render-text-helper-0.2.0 README.md