Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.ruby > #6770

Re: What to do with #<URI::MailTo:0xb762601c URL:mailto:username@company.com>

From Robert Klemme <shortcutter@googlemail.com>
Newsgroups comp.lang.ruby
Subject Re: What to do with #<URI::MailTo:0xb762601c URL:mailto:username@company.com>
Date 2013-03-15 11:49 +0100
Message-ID <aqgcm3Fipl3U1@mid.individual.net> (permalink)
References <f98bb855-178f-47d3-a66e-def382836b4f@googlegroups.com>

Show all headers | View raw


On 15.03.2013 02:24, Thomas Gagne wrote:
> 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:username@company.com>
>
> Being unfamiliar with Ruby, I can't tell if by looking at this output there's a way for me to get username@company.com 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


-- 
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

Back to comp.lang.ruby | Previous | NextPrevious in thread | Find similar


Thread

What to do with #<URI::MailTo:0xb762601c URL:mailto:username@company.com> Thomas Gagne <tggagne@gmail.com> - 2013-03-14 18:24 -0700
  Re: What to do with #<URI::MailTo:0xb762601c URL:mailto:user...@company.com> Thomas Gagne <tggagne@gmail.com> - 2013-03-14 18:35 -0700
  Re: What to do with #<URI::MailTo:0xb762601c URL:mailto:username@company.com> Robert Klemme <shortcutter@googlemail.com> - 2013-03-15 11:49 +0100

csiph-web