Module: HyperNavigator

Defined in:
lib/hyper_navigator.rb,
lib/hyper_navigator/node.rb,
lib/hyper_navigator/version.rb

Defined Under Namespace

Classes: Node, PatternMatcher

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

.get(href, headers = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/hyper_navigator/node.rb', line 7

def self.get(href, headers={})
  uri = URI.parse(href)

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true if uri.scheme == 'https'
  request = Net::HTTP::Get.new(uri.request_uri, headers)

  http.request(request)
end

.post(href, body, headers = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/hyper_navigator/node.rb', line 17

def self.post(href, body, headers={})
  uri = URI.parse(href)

  http = Net::HTTP.new(uri.host, uri.port)
  http.use_ssl = true if uri.scheme == 'https'
  request = Net::HTTP::Post.new(uri.request_uri, headers)
  request.body = body

  http.request(request)
end

.surf(root_url, exp, headers = {}, options = {}) ⇒ Object



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

def self.surf(root_url, exp, headers={}, options={})
  PatternMatcher.new(headers, options).match(root_url, exp)
end