Class: RFacebook::Facepricot

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

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ Facepricot

Returns a new instance of Facepricot.



80
81
82
83
# File 'lib/facepricot.rb', line 80

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



85
86
87
88
89
90
91
# File 'lib/facepricot.rb', line 85

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

#get(key) ⇒ Object



109
110
111
# File 'lib/facepricot.rb', line 109

def get(key)
  return make_facepricot_chain(key.to_s, @doc.containers[0])
end

#hpricotObject



93
94
95
# File 'lib/facepricot.rb', line 93

def hpricot
  return @doc
end

#raw_xmlObject



101
102
103
# File 'lib/facepricot.rb', line 101

def raw_xml
  return @raw_xml
end

#responseObject



97
98
99
# File 'lib/facepricot.rb', line 97

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

#to_sObject



105
106
107
# File 'lib/facepricot.rb', line 105

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