Spiralify 用于将一个数组转成一个Spiral
Spiralify 用于将一个数组转成一个Spiral
Ruby 其它杂项
共18Star
详细介绍
Spiralify
Convert an Array into a Spiral
The best way to get up and running is to check out the Installation section followed by the Examples section.
There also is a Screencast about this project, check it out
Big
Installation
Add this line to your application's Gemfile:
gem 'spiralify'
Or if you're developing a gem and want access to a Spiralify::Spiral
instance, add this line to your application's gemspec:
Gem::Specification.new do |s|
# ...
# ...
spec.add_runtime_dependency('spiralify', '~> 0.1')
# ...
end
And then execute:
$ bundle
If you want to use the spiralify
cli, install it with RubyGems:
$ gem install spiralify
$ spiralify --help
Screencast
Usage
Usage: spiralify [options] args
Examples:
spiralify 1 2,4 3
1 2
4 3
spiralify -p '[[1,2],[4,3]]'
1 2
4 3
spiralify -u 1 2,4 3
1 2 3 4
spiralify -u -t to_i 1 2,4 3
[1, 2, 3, 4]
v0.4.3
Options:
-h, --help Show command line help
-c, --col_sep COL_SEP Column separator (default: ' ')
-r, --row_sep ROW_SEP Row separator (default: ',')
-s, --sub 'ROW COL VAL' input_array[ROW][COL]=VAL
-o, --coords Output center coordinates
-g, --highlight Highlight spiral center
-u, --unspiral Unspiral
-t, --convert_to TO_WHAT Unspiral as array; elements to_* (ex: to_i)(default: to_s)
-p, --process_as_array Process args.first as ruby array
--version Show help/version info
--log-level LEVEL Set the logging level
(debug|info|warn|error|fatal)
(Default: info)
Arguments:
args
Input array to be spiralified
Examples
spiralify 1 2,4 3
1 2
4 3
spiralify --col_sep ',' --row_sep ';' --unspiral '1,2;4,3'
1 2 3 4
spiralify -u --process_as_array '[[1,2,3],[8,9,4],[7,6,5]]'
1 2 3 4 5 6 7 8 9
spiralify -u -p --convert_to to_i '[[1,2,3],[8,9,4],[7,6,5]]'
[1, 2, 3, 4, 5, 6, 7, 8, 9]
spiralify -u -p --convert_to to_f '[[1,2,3],[8,9,4],[7,6,5]]'
[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and tags, and push the .gem
file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mbigras/spiralify. This project follows the Atom Contributing Guidelines.
License
The gem is available as open source under the terms of the MIT License.