Class: Horseman::Action

Inherits:
Object
  • Object
show all
Defined in:
lib/horseman/action.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, response = nil) ⇒ Action

Returns a new instance of Action.



7
8
9
10
# File 'lib/horseman/action.rb', line 7

def initialize(uri, response=nil)
  @uri = uri
  @response = Response.new(response.body, response.to_hash) unless response.nil?
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



5
6
7
# File 'lib/horseman/action.rb', line 5

def response
  @response
end

#uriObject (readonly)

Returns the value of attribute uri.



5
6
7
# File 'lib/horseman/action.rb', line 5

def uri
  @uri
end

Instance Method Details

#relative_rootObject



16
17
18
# File 'lib/horseman/action.rb', line 16

def relative_root
  "#{url.rpartition('/')[0]}/"
end

#urlObject



12
13
14
# File 'lib/horseman/action.rb', line 12

def url
  "#{@uri.scheme}://#{@uri.host}#{@uri.path}" + (@uri.query ? "?#{@uri.query}" : "")
end