Sha256: ecace0fee88760dd29ce3b847a75716f57dfd7c525f3800691451c4e56bfec8b

Contents?: true

Size: 595 Bytes

Versions: 14

Compression:

Stored size: 595 Bytes

Contents

require 'morph'

require 'rubygems'; require 'hpricot'; require 'open-uri'

# 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

14 entries across 14 versions & 1 rubygems

Version Path
morph-0.3.2 examples/hubbit.rb
morph-0.3.1 examples/hubbit.rb
morph-0.3.0 examples/hubbit.rb
morph-0.2.9 examples/hubbit.rb
morph-0.2.8 examples/hubbit.rb
morph-0.2.2 examples/hubbit.rb
morph-0.2.0 examples/hubbit.rb
morph-0.2.1 examples/hubbit.rb
morph-0.2.7 examples/hubbit.rb
morph-0.1.5 examples/hubbit.rb
morph-0.2.5 examples/hubbit.rb
morph-0.2.4 examples/hubbit.rb
morph-0.2.6 examples/hubbit.rb
morph-0.2.3 examples/hubbit.rb