Class: HMachine::Microformat::XFN

Inherits:
POSH::Anchor show all
Defined in:
lib/hmachine/microformat/xfn.rb

Constant Summary collapse

FRIENDLY_NAME =
"XFN"
WIKI_URL =
'http://microformats.org/wiki/XFN'
XMDP =
'http://gmpg.org/xfn/11'
@@friendship =
%w( contact acquaintance friend)
@@physical =
%w( met )
@@professional =
%w( co-worker colleague )
@@geographical =
%w( co-resident neighbor )
@@family =
%w( child parent sibling spouse kin )
@@romantic =
%w( muse crush date sweetheart )
@@identity =
%w( me )
@@relationships =
@@friendship + @@physical + @@professional + @@geographical + @@family + @@romantic + @@identity

Constants included from HMachine

PRODID, VERSION

Instance Attribute Summary

Attributes inherited from POSH::Base

#node, #parent, #source

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from POSH::Anchor

#to_s

Methods inherited from POSH::Base

#[], [], add_property, #each_pair, #empty?, extract, get_properties, has_many, has_many!, has_one, has_one!, #has_property?, inherited, #initialize, many, name, one, parent, #properties, properties, property_of?, remove_nested, search, selector, #to_h, #to_html, #to_s, validate

Methods included from HMachine

#extract, #extract_from, find, #find_in, #found_in?, get, get_document, get_url, map, normalize, #parse, #parse_first, #search, #valid?, #validate

Constructor Details

This class inherits a constructor from HMachine::POSH::Base

Class Method Details

.parse_me(document) ⇒ Object

Performant way to parse identity relationships



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

def self.parse_me(document)
  nodes = document.css("a[rel~='me']")
  if !nodes.empty?
    contents = nodes.collect do |node|
      extract_from(node)
    end
    (contents.length == 1) ? contents.first : contents
  end
end

Instance Method Details

#inspectObject



48
49
50
# File 'lib/hmachine/microformat/xfn.rb', line 48

def inspect
  "<#{self.class}:#{hash}: '#{rel.join(', ')}'>"
end