Double less than Ruby access -
Double less than Ruby access -
i still new ruby , wondering how access info element stored in "double less than" structure:
@email << {:envelope => envelope, :body => body}
if do
<% @results.email.each |result| %> <%= result %> <% end %>
i get
bodytest test envelope#<struct net::imap::envelope date="tue, 28 jun 2011 09:20:35 -0700", subject="test test", from=[#<struct net::imap::address name="some name", route=nil, mailbox="someinbox", host="somehost.com">], sender=[#<struct net::imap::address name="somename", route=nil, mailbox="somebox", host="somedomaincom">], reply_to=[#<struct net::imap::address name="someperson", route=nil, mailbox="somemailbox", host="somehost.com">], to=[#<struct net::imap::address name=nil, route=nil, mailbox="thisinbox", host="somehost.com">], cc=nil, bcc=nil, in_reply_to=nil, message_id="<c4427977-8a42-46e4-adb4-1ae88ed9ccde@mehost.com>">
how access each element, body, envelope, sender (within envelope)? result.body
doesn't work, nor result[body]
.
thanks!
you should utilize result[:body]
, not result[body]
. body
variable, whereas :body
symbol (similar string).
notice have stored values in hash symbols. {:envelope => envelope; :body => body}
storing content of variable envelope
(the 1 on right) value against key :envelope
(and same body
, :body
).
note: nice write on how symbols differ strings - http://www.robertsosinski.com/2009/01/11/the-difference-between-ruby-symbols-and-strings/
ruby-on-rails ruby
Comments
Post a Comment