Class: SiteDiff::UriWrapper::ReadResult

Inherits:
Object
  • Object
show all
Defined in:
lib/sitediff/uriwrapper.rb

Overview

This lets us treat errors or content as one object

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content = nil, encoding = 'utf-8') ⇒ ReadResult

Creates a ReadResult.



32
33
34
35
36
37
# File 'lib/sitediff/uriwrapper.rb', line 32

def initialize(content = nil, encoding = 'utf-8')
  @content = content
  @encoding = encoding
  @error = nil
  @error_code = nil
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



28
29
30
# File 'lib/sitediff/uriwrapper.rb', line 28

def content
  @content
end

#encodingObject

Returns the value of attribute encoding.



28
29
30
# File 'lib/sitediff/uriwrapper.rb', line 28

def encoding
  @encoding
end

#errorObject

Returns the value of attribute error.



28
29
30
# File 'lib/sitediff/uriwrapper.rb', line 28

def error
  @error
end

#error_codeObject

Returns the value of attribute error_code.



28
29
30
# File 'lib/sitediff/uriwrapper.rb', line 28

def error_code
  @error_code
end

Class Method Details

.error(message, code = nil) ⇒ Object

Creates a ReadResult with an error.



41
42
43
44
45
46
# File 'lib/sitediff/uriwrapper.rb', line 41

def self.error(message, code = nil)
  res = new
  res.error_code = code
  res.error = message
  res
end