Forum: Ruby problem in Hash formatted output

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2008-11-29 11:50
Hi All,

I have an Array Like this

@output=[{"accounts"=>["id", "group_id", "company_id", "number", "name",
"opening_balance", "description", "editable", "created_at",
"updated_at", "source_account", "deleted_status", "alias",
"closing_balance", "flag"]},

{"blogs"=>["id", "category_id", "title", "content", "views",
"created_at", "updated_at"]},

{"categories"=>["id", "name"]}
{"clients"=>["id", "first_name", "last_name", "street1", "street2",
"city", "state", "zip", "country", "phone", "fax", "email", "website",
"flag", "created_at", "updated_at"]},

{"companies"=>["id", "client_id", "name", "street1", "street2", "city",
"state", "zip", "country", "phone", "fax", "email", "website", "flag",
"created_at", "updated_at", "business_number", "year_end_date",
"net_days", "selected_province", "tax", "plan_name", "error_display",
"logo_display_flag", "business_type", "user_id"]},

{"company_details"=>["id", "content_type", "filename", "size",
"parent_id", "thumbnail", "width", "height", "db_file_id",
"attachable_type", "attachable_id"]},

{"contacts"=>["id", "company_id", "company_name", "first_name",
"last_name", "title", "street1", "street2", "city", "state", "zip",
"country", "phone", "email", "fax", "website", "contact_type",
"created_at", "updated_at", "account_id", "flag"]},

{"countries"=>["id", "name", "code"]}]


This is my array. I want to get exactly like this Output format

OUTPUT:

01.accounts
 id
 group_id
 company_id
 number
 name
 opening_balance
 description
 editable
 created_at
 updated_at
 source_account
 deleted_status
 alias
 closing_balance
 flag
------------------------
02.blogs
 id
 category_id
 title
 content
 views
 created_at
 updated_at
-----------------------

AND So ON


Please provide a code for it


Thanks,
P.Raveendran
http://raveendran.wordpress.com
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (Guest)
on 2008-11-29 12:41
(Received via mailing list)
On 29.11.2008 11:45, jazzez ravi wrote:

> I have an Array Like this

> This is my array. I want to get exactly like this Output format

> Please provide a code for it

Another attempt to abuse the community to write code for free.  For this
to work you should provide a much more interesting problem than
formatting output of a nested data structure.

Alternative show the code you have got so far and we'll be happily
helping out where you have problems.

Regards

  robert
Cf7cd97cdc8ed7d4ae92965b24f0dfad?d=identicon&s=25 Stefan Rusterholz (apeiros)
on 2008-11-29 15:02
jazzez ravi wrote:
> Hi All,
>
> I have an Array Like this
*snip*
> This is my array. I want to get exactly like this Output format
*snip*
> Please provide a code for it

There is a difference between *help* and *solutions*. Help you might get
for free here (depends a lot on you, e.g. attitude, proper information
etc.), but if you want solutions, go and get some contractor. That's
what you *pay* for.

Regards
Stefan
3d401468ea7d69980d5cf9ecd18ce65a?d=identicon&s=25 Constantine Karnacevych (digital)
on 2008-11-30 22:42
Stefan Rusterholz wrote:
> jazzez ravi wrote:
>> Hi All,
>>
>> I have an Array Like this
> *snip*
>> This is my array. I want to get exactly like this Output format
> *snip*
>> Please provide a code for it
>
> There is a difference between *help* and *solutions*. Help you might get
> for free here (depends a lot on you, e.g. attitude, proper information
> etc.), but if you want solutions, go and get some contractor. That's
> what you *pay* for.

2 jazzez ravi =>
 agreed :)

2 Stefan Rusterholz =>
what for do you need this
for debugging reason you may use 'pp'
eg. require 'pp'; pp @output

else you have to write your own method if you need this being
implemented
a lot of samples exist in the network, just carefully dig
Da22709962fc0cf31068e779c78ab6be?d=identicon&s=25 Raveendran .P (jazzezravi)
on 2008-12-01 05:07
Hi All,

Thanks for your kind information. I requested to my client for provide a
full code to me. And also suggest the output format like this,

accounts=["id",
 "group_id",
 "company_id",
 "number",
" name",
" opening_balance",
" description",
" editable",
" updated_at",
" source_account",
" deleted_status",
" alias",
" closing_balance",
" flag"]

output=[accounts,blogs]

I have only the above output format which is mentioned the Top of the
Post.Thats why asking suggestion from U Guys. Anyway let u know after
getting info from My client.

Thanks,
P.Raveendran
http://raveendran.wordpress.com
This topic is locked and can not be replied to.