Class: RFacebook::Facepricot

Inherits:
Object
  • Object
show all
Includes:
FacepricotChaining
Defined in:
lib/facepricot.rb

Instance Method Summary collapse

Methods included from FacepricotChaining

#make_facepricot_chain

Constructor Details

#initialize(xml) ⇒ Facepricot

Returns a new instance of Facepricot.



82
83
84
85
# File 'lib/facepricot.rb', line 82

def initialize(xml)
  @doc = Hpricot.XML(xml)
  @raw_xml = xml
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(methodSymbol, *params) ⇒ Object



87
88
89
90
91
92
93
# File 'lib/facepricot.rb', line 87

def method_missing(methodSymbol, *params)
  begin
    @doc.method(methodSymbol).call(*params) # pose as Hpricot document
  rescue
    return make_facepricot_chain(methodSymbol.to_s, @doc.containers[0])
  end
end

Instance Method Details

#hpricotObject



95
96
97
# File 'lib/facepricot.rb', line 95

def hpricot
  return @doc
end

#raw_xmlObject



103
104
105
# File 'lib/facepricot.rb', line 103

def raw_xml
  return @raw_xml
end

#responseObject



99
100
101
# File 'lib/facepricot.rb', line 99

def response
  return FacepricotChain.new(@doc.containers[0])
end

#to_sObject



107
108
109
# File 'lib/facepricot.rb', line 107

def to_s
  return @doc.containers[0].inner_html
end