Sha256: 2c8aa891927b8dd97f26622525781ec79dc9e2a612dc25ba2daff4c5019e205b

Contents?: true

Size: 576 Bytes

Versions: 2

Compression:

Stored size: 576 Bytes

Contents

require 'hpricot'; require 'open-uri'; require 'morph'

# An example of Morph playing with Hpricot
class Hubbit

  include Morph

  def initialize name
    begin
      doc = Hpricot open("http://github.com/#{name}")

      (doc/'label').collect do |node|
        label = node.inner_text
        value = node.next_sibling.inner_text.strip

        morph(label, value) # magic morphing happening here!
      end
    rescue
      raise "Couldn't find hubbit with name: #{name}"
    end
  end
end

def Hubbit name
  Hubbit.new name
end

# why = Hubbit 'why'
# dhh = Hubbit 'dhh'

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
morph-0.1.2 examples/hubbit.rb
morph-0.1.0 examples/hubbit.rb