# How do I access the following?

**URL:** <https://www.ruby-forum.com/t/how-do-i-access-the-following/180299>\
**Category:** Ruby\
**Created:** [December 16, 2009, 11:56pm UTC](https://www.ruby-forum.com/t/how-do-i-access-the-following/180299 "2009-12-16T23:56:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hawken](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hawken](https://www.ruby-forum.com/u/hawken)\
**Post date:** [December 16, 2009, 11:56pm UTC](https://www.ruby-forum.com/t/how-do-i-access-the-following/180299/1 "2009-12-16T23:56:35Z")

</div>

Noob question, if there is a better venue for this sort of question show  
me. Thanks.

How could I access “Seen” displayed below?

[#\<struct Net::IMAP::FetchData seqno=1, attr={“FLAGS”=\>[:Seen]}\>]

---

<div class="post-metadata">

**Author:** ![hawken](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hawken](https://www.ruby-forum.com/u/hawken)\
**Post date:** [December 17, 2009, 12:09am UTC](https://www.ruby-forum.com/t/how-do-i-access-the-following/180299/2 "2009-12-17T00:09:57Z")

</div>

You have an Array with one Struct. Get the Struct, and call the FLAGS  
method. Or use [“FLAGS”].

Mind you, FLAGS is also an Array, that could contain more flags than  
:Seen. See the “include?” or “detect” methods on Array.

There’s also a chance your object has a method that does that for you.  
Maybe “seen?”. Never used Net::IMAP.

Good luck!

---

<div class="post-metadata">

**Author:** ![hawken](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hawken](https://www.ruby-forum.com/u/hawken)\
**Post date:** [December 17, 2009, 6:11am UTC](https://www.ruby-forum.com/t/how-do-i-access-the-following/180299/3 "2009-12-17T06:11:47Z")

</div>

Jordi B. wrote:

> You have an Array with one Struct. Get the Struct, and call the FLAGS  
> method. Or use [“FLAGS”].
> 
> Mind you, FLAGS is also an Array, that could contain more flags than  
> :Seen. See the “include?” or “detect” methods on Array.
> 
> There’s also a chance your object has a method that does that for you.  
> Maybe “seen?”. Never used Net::IMAP.
> 
> Good luck!

Thanks! FLAGS can have multiple items in it, but I know for certain that  
IMAP server I’m working on will always only have one item or none at  
all.

I got it by doing the following. I wonder is there a better way, what  
I’m doing seems redundant but it’s how I got it to work.

imap = Net::IMAP.new(‘[imap.mydomain.com](http://imap.mydomain.com)’)  
…  
status = imap.fetch(message\_id, ‘FLAGS’)[0].attr[‘FLAGS’]

if (status[0]).nil? then  
status[0] = “UNREAD”  
else  
status[0] = “READ”  
end
