Skip to content

Ruby Blender

  • Blog
  • About
  • Archives
  • Log in
 
Less
More
Trim
Untrim
« Older
Home
Loading
Newer »
Tag Archive for 'mini-saga'
14Feb09 Open-uri makes for developer friendly I/O
mini-saga programming ruby
0 Comments
A Venn diagram of Uniform Resource Identifier ...
Image via Wikipedia

open-uri, a part of the standard Ruby distribution, makes opening and reading from a URI easy. With it, developers use familiar methods like open for performing I/O with URI’s.

require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
f.each_line {|line| p line}
}

Contrast Net::HTTP which uses numerous methods to achieve the same effect.

require 'net/http'

url = URI.parse('http://www.example.com/index.html')
req = Net::HTTP::Get.new(url.path)
res = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts res.body

An addon, SuperIO, adds more flexiblity in attempting to DTRT.

Enhanced by Zemanta
13Feb09 Ruby Mini Sagas
administrivia ruby
0 Comments

Elsewhere I’ve written about mini-sagas. I’m setting a goal to write one about a ruby topic daily. It will limit me to fifty words. But there certainly can be a great deal of freedom arising through constraints. It’s been said, in fact, that Creativity loves constraints. Here’s to creative constraint!

Enhanced by Zemanta
 
Browse Archives »
  • administrivia (2)
  • configuration (1)
  • metaprogramming (1)
  • mini-saga (5)
  • programming (10)
  • rails (1)
  • ruby (15)
  • rubygems (2)
  • Uncategorized (1)
 

Recent Posts

  • Default values for Attributes
  • Arguments with Trollop
  • Database Paranoia — ActiveRecord Callbacks
  • Ruby Bindings and Scope
  • What’s #method_missing missing?

Search

Browse by Category

  • administrivia (2)
  • configuration (1)
  • metaprogramming (1)
  • mini-saga (5)
  • programming (10)
  • rails (1)
  • ruby (15)
  • rubygems (2)
  • Uncategorized (1)

Browse by Tag

  • ActiveRecord
  • binding
  • Command-line interface
  • gotcha
  • irb
  • irbc
  • Languages
  • Library
  • Local variable
  • metaprogramming
  • mini-saga
  • paradigm
  • philosophy
  • programming
  • rails
  • Recursion
  • ruby
  • rubygems
  • Ruby on Rails
  • scope
  • utilities

Browse by Month

  • September 2009 (1)
  • August 2009 (4)
  • April 2009 (1)
  • February 2009 (11)
 
 
  • Blog
  • About
  • Archives
  • Log in
 


Theme Design by Jay Kwong | Powered by WordPress and K2

 

Home Top Archives Entries FeedComments Feed