Class: Naver::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/naver/client.rb

Overview

Common functionality across Naver API objects.

Direct Known Subclasses

Map, Papago, Profile, Search, Shorturl, Vision, Voice

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.connectionNaver::Connection

The connection object being used to communicate with Naver.

Returns:


30
31
32
# File 'lib/naver/client.rb', line 30

def connection
  @@connection ||= Connection.new
end

.connection=(conn) ⇒ Naver::Connection

Assign a default connection object.

Parameters:

Returns:


37
38
39
# File 'lib/naver/client.rb', line 37

def connection=(conn)
  @@connection = conn
end

.parse(body) ⇒ Object

Converts the response body to an ObjectifiedHash.


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/naver/client.rb', line 11

def self.parse(body)
  if body.is_a?(Hash)
    ObjectifiedHash.new(body)
  elsif body.is_a?(Array)
    body.collect! { |e| ObjectifiedHash.new(e) }
  elsif body
    true
  elsif !body
    false
  elsif body.nil?
    false
  else
    raise Naver::Error.new("Couldn't parse a response body")
  end
end

Instance Method Details

#connectionNaver::Connection

The connection object being used to communicate with Naver.

Returns:


6
7
8
# File 'lib/naver/client.rb', line 6

def connection
  self.class.connection
end