Module: UrlHandler

Included in:
Lang
Defined in:
lib/nlp_toolz/helpers/url_handler.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(receiver) ⇒ Object



23
24
25
# File 'lib/nlp_toolz/helpers/url_handler.rb', line 23

def self.included(receiver)
  receiver.extend ClassMethods
end

Instance Method Details

#build_url(host, port, path, query) ⇒ Object

instance methods



9
10
11
12
# File 'lib/nlp_toolz/helpers/url_handler.rb', line 9

def build_url(host, port, path, query)
  return URI::HTTP.build({:host => host, :path => path, :query => query}) if port.nil?
  return URI::HTTP.build({:host => host, :port => port, :path => path, :query => query}) unless port.nil?
end

#post_data(content, uri, content_type) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/nlp_toolz/helpers/url_handler.rb', line 15

def post_data(content,uri,content_type)
  post = Net::HTTP::Post.new(uri.request_uri,content_type)
  post.body = content.force_encoding("utf-8")
  uri_response = Net::HTTP.start(uri.host,uri.port) {|http| http.request(post)}
  
  uri_response
end