Class: Preposterous::Base
- Inherits:
-
Object
- Object
- Preposterous::Base
show all
- Extended by:
- Forwardable
- Defined in:
- lib/preposterous/base.rb,
lib/preposterous/connection.rb
Direct Known Subclasses
Post
Defined Under Namespace
Classes: ClientTypeNotSpecified
Constant Summary
collapse
- @@client =
the following code is to allow for a active_record-y access to Posterous
nil
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(client) ⇒ Base
Returns a new instance of Base.
8
9
10
|
# File 'lib/preposterous/base.rb', line 8
def initialize(client)
@client = client
end
|
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
6
7
8
|
# File 'lib/preposterous/base.rb', line 6
def client
@client
end
|
Class Method Details
.client ⇒ Object
9
10
11
|
# File 'lib/preposterous/connection.rb', line 9
def self.client
@@client
end
|
.establish_client(config = {}) ⇒ Object
13
14
15
16
17
|
# File 'lib/preposterous/connection.rb', line 13
def self.establish_client(config={})
unless config.key?(:client_type) then raise ClientTypeNotSpecified, "You must specify an adapter type" end
client = config[:client_type].initialize_from_hash(config)
@@client = new(client)
end
|
Instance Method Details
#getsites ⇒ Object
12
13
14
15
16
17
|
# File 'lib/preposterous/base.rb', line 12
def getsites
response = perform_get("/api/getsites")
response["site"] if not response.nil?
end
|
49
50
51
52
|
# File 'lib/preposterous/base.rb', line 49
def gettags
response = perform_get("/api/gettags")
response["tag"] if not response.nil?
end
|
44
45
46
47
|
# File 'lib/preposterous/base.rb', line 44
def (fields={})
response = perform_post("/api/newcomment", :fields => fields)
response["comment"] if not response.nil?
end
|
#newpost(fields = {}, *files) ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'lib/preposterous/base.rb', line 19
def newpost(fields={}, *files)
options = generate_post_options(fields, *files)
puts options
response = perform_post("/api/newpost", options)
response["post"] if not response.nil?
end
|
#readposts(fields = {}) ⇒ Object
this is BROKEN for some reason the XML will not parse the CDATA fields are throwing off the parser(REXML)
39
40
41
42
|
# File 'lib/preposterous/base.rb', line 39
def readposts(fields={})
response = perform_get("/api/readposts", :fields => fields)
response["post"] if not response.nil?
end
|
#updatepost(fields = {}, *files) ⇒ Object
28
29
30
31
32
33
34
|
# File 'lib/preposterous/base.rb', line 28
def updatepost(fields={}, *files)
options = generate_post_options(fields, *files)
response = perform_post("/api/updatepost", options)
response["post"] if not response.nil?
end
|