What to do with #<URI::MailTo:0xb762601c URL:mailto:[email protected]>

T

Thomas Gagne

I'm trying to figure out how Ruby might unpack an .ics file for me.

When I look at a meeting's attendee and inspect the variable it outputs as

#<URI::MailTo:0xb762601c URL:mailto:[email protected]>

Being unfamiliar with Ruby, I can't tell if by looking at this output there's a way for me to get (e-mail address removed) from the variable or not.

If reading the code helps, it's below.

tgagne@ubuntu:~/work/heroku/ruby-sample$ cat test.rb
require 'rubygems'
require 'icalendar'
require 'date'

invite = File.open("invite.ics")

cals = Icalendar.parse(invite)

for each in cals do
puts each.inspect
puts

for eachEvent in each.events do
puts eachEvent.summary
puts eachEvent.description
puts eachEvent.location
puts eachEvent.status
puts eachEvent.dtstart
puts eachEvent.dtend
puts
puts eachEvent.organizer.inspect
for eachAttendee in eachEvent.attendees do
puts eachAttendee.inspect
end

end
end
 
T

Thomas Gagne

I figured it out.

#<URI

is telling me the object is a uri class or something of mailto:

I looked up the doc for URI, found its subclass mailto, and discovered "to" to get the user's email.

Yea!
 
R

Robert Klemme

I'm trying to figure out how Ruby might unpack an .ics file for me.

When I look at a meeting's attendee and inspect the variable it outputs as

#<URI::MailTo:0xb762601c URL:mailto:[email protected]>

Being unfamiliar with Ruby, I can't tell if by looking at this output there's a way for me to get (e-mail address removed) from the variable or not.

If reading the code helps, it's below.

tgagne@ubuntu:~/work/heroku/ruby-sample$ cat test.rb
require 'rubygems'
require 'icalendar'
require 'date'

invite = File.open("invite.ics")

Btw you're not closing the file properly. Also, you might want to open
the file with a specific encoding. RFC 2445 does seem to indicate that
we're facing a binary encoding (section 3.4, I didn't read too
extensively though).
http://www.ietf.org/rfc/rfc2445.txt
cals = Icalendar.parse(invite)

for each in cals do

"each" does not seem to be a good variable name here. Why not "entry"?
puts each.inspect

p each
puts

for eachEvent in each.events do
puts eachEvent.summary
puts eachEvent.description
puts eachEvent.location
puts eachEvent.status
puts eachEvent.dtstart
puts eachEvent.dtend

You can combine that in a single puts statement.
puts
puts eachEvent.organizer.inspect
for eachAttendee in eachEvent.attendees do
puts eachAttendee.inspect
end

end
end

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top