Class: Philologic::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/philologic-client.rb,
lib/philologic-client/link.rb,
lib/philologic-client/version.rb,
lib/philologic-client/document.rb,
lib/philologic-client/response.rb,
lib/philologic-client/frequency.rb,
lib/philologic-client/occurrence.rb,
lib/philologic-client/collocation.rb,
lib/philologic-client/concordance.rb,
lib/philologic-client/bibliography.rb,
lib/philologic-client/frequency_row.rb

Overview

:nodoc:

Defined Under Namespace

Classes: Bibliography, Collocation, Concordance, Document, Frequency, FrequencyRow, Link, Occurrence, Response

Constant Summary collapse

DEFAULT_ENCODING =

Default encoding.

'utf-8'
VERSION =

Philologic::Client version

'0.2.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(endpoint = nil) {|_self| ... } ⇒ Client

Initialize Philologic::Client

Params:

endpoint

Philologic endpoint (defaults to nil)

Yields:

  • (_self)

Yield Parameters:



152
153
154
155
156
157
# File 'lib/philologic-client.rb', line 152

def initialize( endpoint = nil )
  @encoding = DEFAULT_ENCODING
  @endpoint = endpoint
  yield self if block_given?
  self
end

Instance Attribute Details

#encodingObject

Get/Set encoding



139
140
141
# File 'lib/philologic-client.rb', line 139

def encoding
  @encoding
end

#endpointObject

Get/Set endpoint



144
145
146
# File 'lib/philologic-client.rb', line 144

def endpoint
  @endpoint
end

Instance Method Details

#bibliographyObject

Returns Philologic::Client::Bibliography object or nil



162
163
164
165
# File 'lib/philologic-client.rb', line 162

def bibliography
  result = _query( 'method' => 'proxy', 'q' => '' )
  return result.kind_of?(Philologic::Client::Bibliography) ? result : nil
end

#collocation(query) ⇒ Object

Return Philologic::Client::Collocation object or nil.

Params:

query

Search for this query string.



173
174
175
176
177
178
# File 'lib/philologic-client.rb', line 173

def collocation(query)
  raise('nil query') if ( query.nil? || !( [ Hash,  String ].include?( query.class ) )) || query.empty?
  defaults = { :method => 'proxy', :report => 'collocation' }
  r = _query( query.kind_of?(String) ? defaults.merge( :q => query ) : defaults.merge(query) )
  return r.kind_of?(Philologic::Client::Collocation) ? r : nil
end

#concordance(query) ⇒ Object

Return Philologic::Client::Concordance object or nil.

Params:

query

Search for this query string.



186
187
188
189
190
191
# File 'lib/philologic-client.rb', line 186

def concordance(query)
  raise('nil query') if ( query.nil? || !( [ Hash,  String ].include?( query.class ) )) || query.empty?
  defaults = { :method => 'proxy', :report => 'concordance' }
  r = _query( query.kind_of?(String) ? defaults.merge( :q => query ) : defaults.merge(query) )
  return r.kind_of?(Philologic::Client::Concordance) ? r : nil
end

#document(path) ⇒ Object

Return object extending Philologic::Client::Document class or nil.

Params:

path

Return document at this path



199
200
201
202
# File 'lib/philologic-client.rb', line 199

def document(path)
  doc = _get(path)
  doc.kind_of?(::Philologic::Client::Document) ? doc : nil
end

#frequency(query) ⇒ Object

Return Philologic::Client::Frequency object or nil.

Params:

query

Search for this query string.



210
211
212
213
214
215
# File 'lib/philologic-client.rb', line 210

def frequency(query)
  raise('nil query') if ( query.nil? || !( [ Hash,  String ].include?( query.class ) )) || query.empty?
  defaults = { :method => 'proxy', :report => 'frequency' }
  r = _query( query.kind_of?(String) ? defaults.merge( :q => query ) : defaults.merge(query) )
  return r.kind_of?(Philologic::Client::Frequency) ? r : nil
end