Class: Socrata
- Inherits:
-
Object
- Object
- Socrata
- Includes:
- HTTParty
- Defined in:
- lib/socrata/data.rb,
lib/socrata.rb
Overview
Copyright © 2010 Socrata.
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Direct Known Subclasses
Defined Under Namespace
Constant Summary collapse
- DEFAULT_CONFIG =
{ :base_uri => "http://www.socrata.com/api" }
Instance Attribute Summary collapse
-
#batching ⇒ Object
readonly
Returns the value of attribute batching.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
-
#batch_request ⇒ Object
Wrap a proc for a batch request.
-
#initialize(params = {}) ⇒ Socrata
constructor
A new instance of Socrata.
- #user(uid_or_login) ⇒ Object
- #view(uid) ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Socrata
Returns a new instance of Socrata.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/socrata.rb', line 41 def initialize(params = {}) @config = DEFAULT_CONFIG.merge(Util.symbolize_keys(params)) @logger = @config[:logger] || Logger.new(STDOUT) @batching = false @batch_queue = [] if @config[:username] self.class.basic_auth(@config[:username], @config[:password]) else self.class.[:basic_auth] = nil end self.class.base_uri @config[:base_uri] # Keep around a self reference because we need it @party = self.class end |
Instance Attribute Details
#batching ⇒ Object (readonly)
Returns the value of attribute batching.
32 33 34 |
# File 'lib/socrata.rb', line 32 def batching @batching end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
32 33 34 |
# File 'lib/socrata.rb', line 32 def config @config end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
32 33 34 |
# File 'lib/socrata.rb', line 32 def error @error end |
Instance Method Details
#batch_request ⇒ Object
Wrap a proc for a batch request
69 70 71 72 73 74 75 |
# File 'lib/socrata.rb', line 69 def batch_request() @batching = true @batch_queue = [] yield @batching = false flush_batch_queue(); end |