Class: WebFetch::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/web_fetch/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/web_fetch/result.rb', line 7

def initialize(options = {})
  @pending = options.fetch(:pending, false)
  return if pending?

  @body = options.fetch(:body)
  @headers = options.fetch(:headers)
  @status = options.fetch(:status)
  @success = options.fetch(:success)
  @error = options.fetch(:error)
  @uid = options.fetch(:uid)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



5
6
7
# File 'lib/web_fetch/result.rb', line 5

def body
  @body
end

#errorObject (readonly)

Returns the value of attribute error.



5
6
7
# File 'lib/web_fetch/result.rb', line 5

def error
  @error
end

#headersObject (readonly)

Returns the value of attribute headers.



5
6
7
# File 'lib/web_fetch/result.rb', line 5

def headers
  @headers
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/web_fetch/result.rb', line 5

def status
  @status
end

#uidObject (readonly)

Returns the value of attribute uid.



5
6
7
# File 'lib/web_fetch/result.rb', line 5

def uid
  @uid
end

Instance Method Details

#complete?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/web_fetch/result.rb', line 23

def complete?
  !pending?
end

#pending?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/web_fetch/result.rb', line 19

def pending?
  @pending
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/web_fetch/result.rb', line 27

def success?
  @success
end