Class: Tobacco::Error
- Inherits:
-
Object
- Object
- Tobacco::Error
- Defined in:
- lib/tobacco/error.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#filepath ⇒ Object
Returns the value of attribute filepath.
-
#msg ⇒ Object
Returns the value of attribute msg.
-
#object ⇒ Object
Returns the value of attribute object.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Error
constructor
A new instance of Error.
-
#to_a ⇒ Object
(also: #to_ary)
Allow destructure of the error into variable names.
Constructor Details
#initialize(options = {}) ⇒ Error
Returns a new instance of Error.
12 13 14 15 16 17 |
# File 'lib/tobacco/error.rb', line 12 def initialize( = {}) self.msg = [:msg] self.filepath = [:filepath] self.content = [:content] self.object = [:object] end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
10 11 12 |
# File 'lib/tobacco/error.rb', line 10 def content @content end |
#filepath ⇒ Object
Returns the value of attribute filepath.
10 11 12 |
# File 'lib/tobacco/error.rb', line 10 def filepath @filepath end |
#msg ⇒ Object
Returns the value of attribute msg.
10 11 12 |
# File 'lib/tobacco/error.rb', line 10 def msg @msg end |
#object ⇒ Object
Returns the value of attribute object.
10 11 12 |
# File 'lib/tobacco/error.rb', line 10 def object @object end |
Instance Method Details
#to_a ⇒ Object Also known as: to_ary
Allow destructure of the error into variable names
eg.
msg, filepath, content, object = *error
[ 'Error writing file', '/path/to/file', '<h1>Title</h1>', #<Errno::EACCES: Permission denied - /users/index.txt> ]
You can access the attributes normally as well
error.msg #=> 'Error writing file'
error.filepath #=> '/path/to/file'
error.object #=> #<Errno::EACCES: Permission denied - /users/index.txt>
32 33 34 |
# File 'lib/tobacco/error.rb', line 32 def to_a [ msg, filepath, content, object ] end |