Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamesmartin/counterstring
Counter strings are self documenting strings with respect to their length. This class will create counter strings of arbitrary length.
https://github.com/jamesmartin/counterstring
Last synced: 2 months ago
JSON representation
Counter strings are self documenting strings with respect to their length. This class will create counter strings of arbitrary length.
- Host: GitHub
- URL: https://github.com/jamesmartin/counterstring
- Owner: jamesmartin
- Created: 2010-07-22T12:40:51.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2015-10-11T07:53:03.000Z (about 9 years ago)
- Last Synced: 2024-09-17T03:36:00.494Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 107 KB
- Stars: 7
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Counter strings are self documenting strings with respect to their length. CounterString is a class that creates counter strings of arbitrary length.
James Bach, [describes counter strings](http://www.satisfice.com/blog/archives/22) as follows:
"A counterstring is a graduated string of arbitrary length. No matter where you are in the string, you always know the character position. This comes in handy when you are pasting huge strings into fields and they get truncated at a certain point. You want to know how many characters that is."
Here's a simple example of its use as a library:
```ruby
require 'rubygems'
require 'counter_string'cs = CounterString.new
p cs.generate 35
=> "2*4*6*8*11*14*17*20*23*26*29*32*35*"
```It's easy to generate counter strings from the command line, too (thanks [@hogfish](https://github.com/hogfish)):
```
$ counter_string 10
2*4*6*8*11
```The counter string is automatically copied to your clipboard.