Class: Backend

Inherits:
Object
  • Object
show all
Defined in:
lib/picky-live/backend.rb

Overview

Ruby Live Interface to the Picky search engine.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Backend

Returns a new instance of Backend.



9
10
11
12
13
# File 'lib/picky-live/backend.rb', line 9

def initialize options = {}
  @host = options[:host] || 'localhost'
  @port = options[:port] || 8080
  @path = options[:path] || '/admin'
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



7
8
9
# File 'lib/picky-live/backend.rb', line 7

def host
  @host
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/picky-live/backend.rb', line 7

def path
  @path
end

#portObject (readonly)

Returns the value of attribute port.



7
8
9
# File 'lib/picky-live/backend.rb', line 7

def port
  @port
end

Instance Method Details

#get(params = {}) ⇒ Object



15
16
17
18
19
# File 'lib/picky-live/backend.rb', line 15

def get params = {}
  query_params = params.to_query
  query_params = "?#{query_params}" unless query_params.empty?
  Net::HTTP.get self.host, "#{self.path}#{query_params}", self.port
end