Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/camertron/rtl-string
Easier string manipulation for people who come from LTR backgrounds.
https://github.com/camertron/rtl-string
Last synced: 18 days ago
JSON representation
Easier string manipulation for people who come from LTR backgrounds.
- Host: GitHub
- URL: https://github.com/camertron/rtl-string
- Owner: camertron
- License: apache-2.0
- Created: 2013-09-18T20:59:27.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-19T00:04:02.000Z (over 11 years ago)
- Last Synced: 2024-11-04T00:42:04.364Z (2 months ago)
- Language: Ruby
- Size: 141 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: History.txt
- License: LICENSE
Awesome Lists containing this project
README
rtl-string
==========Easier string manipulation for people who come from LTR backgrounds.
### Usage
Create a new `RtlString` instance with some Arabic text. Calling `.to_s` will show an LTR representation of the string. You should read it from left to right, just like you would an English string:
```ruby
arabic_str = [1575, 1605, 32, 98, 108, 97, 114, 103, 32, 1576, 1573, 1590].pack("U*")
RtlString.new(arabic_str).to_s # => "[alef][meem] blarg [beh][alef - hamza below][dad]"
```You can also call `.to_rtl_s` on a regular string:
```ruby
arabic_str.to_rtl_s # => "[alef][meem] blarg [beh][alef - hamza below][dad]"
```### String Operations
Instances of `RtlString` respond to a few additional string operations, including `delete_at`, `insert`, `[]`, and `size`:
```ruby
str = arabic_str.to_rtl_s
str.delete_at(1) # => "[meem]"
str.delete_range(1..2)
str.insert([1605].pack("U*"), 1)
str.to_s # => "[alef][meem][meem] blarg [beh][alef - hamza below][dad]"
str[1] # => "[meem]
str[1..3] # => "[meem] b"
str.size # => 12
str.length # => 12
```### Requirements
Depends on the [twitter-cldr-rb](https://github.com/twitter/twitter-cldr-rb) gem.
### Running Tests
`bundle exec rspec`
### Authors
* Cameron C. Dutro: http://github.com/camertron