Structformatter
Structformatter extends ruby Structs, Arrays, and Hashes to be outputted as yaml, xml, and json.
Installation
Add this line to your application's Gemfile:
gem 'structformatter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install structformatter
Usage
require 'structformatter'
class TestStruct < Struct.new(:apple,:bottle,:can,:donut); end
a = [1,'test',1.0,1e-9]
b = {'a'=>1, 'b'=>1.0, 'c'=>1e-9, 'd'=>'test'}
c = TestStruct.new(1,1.0,1e-9,'test')
a.to_xml
a.to_json
a.to_s
b.to_xml
b.to_json
b.to_s
c.to_xml
c.to_json
c.to_s(",")
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request