Class: Bdz::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.



7
8
9
10
11
12
13
14
# File 'lib/bdz/client.rb', line 7

def initialize
  @params = {}
  @faraday_client = Faraday.new(:url => Bdz::ROOT_URL) do |faraday|
    faraday.request  :url_encoded             # form-encode POST params
    faraday.response :logger                  # log requests to STDOUT
    faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
  end
end

Instance Attribute Details

#faraday_clientObject (readonly)

Returns the value of attribute faraday_client.



5
6
7
# File 'lib/bdz/client.rb', line 5

def faraday_client
  @faraday_client
end

#paramsObject (readonly)

Returns the value of attribute params.



4
5
6
# File 'lib/bdz/client.rb', line 4

def params
  @params
end

Instance Method Details

#search(params = {}) ⇒ Object

client.search(=> “Пловдив”, :to_station => “София”, :date => “20/08/2012”)



17
18
19
20
21
# File 'lib/bdz/client.rb', line 17

def search(params = {})
  content = get(params)
  parser = Bdz::Parser::Schedule.new content
  parser.parse
end