Module: HMachine::Microformat

Defined in:
lib/hmachine/microformat.rb,
lib/hmachine/microformat/adr.rb,
lib/hmachine/microformat/geo.rb,
lib/hmachine/microformat/xfn.rb,
lib/hmachine/microformat/xmdp.rb,
lib/hmachine/microformat/xoxo.rb,
lib/hmachine/microformat/hcard.rb,
lib/hmachine/microformat/reltag.rb,
lib/hmachine/microformat/votelinks.rb,
lib/hmachine/microformat/rellicense.rb

Defined Under Namespace

Classes: Adr, Geo, HCard, RelLicense, RelTag, VoteLinks, XFN, XMDP, XOXO

Class Method Summary collapse

Class Method Details

.find(html, uformat = nil) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/hmachine/microformat.rb', line 22

def self.find(html, uformat = nil)
  if uformat
    map(uformat).parse HMachine.get(html)
  else
    find_all(html)
  end
end

.find_all(html) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/hmachine/microformat.rb', line 30

def self.find_all(html)
  doc = HMachine.get(html)
  uformats = microformats.values.collect do |uf|
    uf.parse(doc)
  end
  uformats.compact.flatten
end

.map(name) ⇒ Object



4
5
6
7
8
# File 'lib/hmachine/microformat.rb', line 4

def self.map(name)
  map = microformats[HMachine.normalize(name)]
  raise "#{name} is not a recognized microformat." unless map
  map
end

.microformatsObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/hmachine/microformat.rb', line 10

def self.microformats
  { :hcard      => HMachine::Microformat::HCard,
    :geo        => HMachine::Microformat::Geo,
    :adr        => HMachine::Microformat::Adr,
    :rellicense => HMachine::Microformat::RelLicense,
    :reltag     => HMachine::Microformat::RelTag,
    :votelinks  => HMachine::Microformat::VoteLinks,
    :xfn        => HMachine::Microformat::XFN,
    :xmdp       => HMachine::Microformat::XMDP,
    :xoxo       => HMachine::Microformat::XOXO }
end