Sha256: 5c08b9f055e43fdc5d40a14304f64a0d43bcb028de2b799fed9c66de8012b1d6

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 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 three parameters. 
"limit" which is defaulted to 32 and controls how far to show the characters.
"more_indicator" which defaults to "." and controls which character to use to indicate there are more.
"indicator_length" which defaults to 3 and controls how many times to show the more indicator.

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

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

'elephant'.limit_print(limit: 2, indicator_length: 0)
'el'

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

'elephant'.limit_print(limit: 4, more_indicator: '*', indicator_length: 2)
'elep**'
```

### 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'
```

### to_i

Returns 1 for true and 0 for false on a boolean object.

## 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.3.0 README.md