Class: NackClass
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Instance Method Summary collapse
- #==(x) ⇒ Object
- #call(*args) ⇒ Object
- #call_with_data ⇒ Object
-
#initialize(error = nil, *data, &ctrl) ⇒ NackClass
constructor
A new instance of NackClass.
- #method_missing(meth, *args) ⇒ Object
- #raise_error ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(error = nil, *data, &ctrl) ⇒ NackClass
Returns a new instance of NackClass.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/carat/nack.rb', line 56 def initialize(error=nil, *data, &ctrl) if Class === error and error <= Exception @error = error.new(*data) elsif error.kind_of?( Exception ) @error = error elsif error.kind_of?( String ) @error = StandardError.new(error) elsif error == nil @error = StandardError.new else raise InvalidNackError end @data = data @ctrl = ctrl end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
90 91 92 |
# File 'lib/carat/nack.rb', line 90 def method_missing(meth, *args) raise_error end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
54 55 56 |
# File 'lib/carat/nack.rb', line 54 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
54 55 56 |
# File 'lib/carat/nack.rb', line 54 def error @error end |
Instance Method Details
#call(*args) ⇒ Object
72 73 74 |
# File 'lib/carat/nack.rb', line 72 def call(*args) @ctrl.call(*args) end |
#call_with_data ⇒ Object
76 77 78 |
# File 'lib/carat/nack.rb', line 76 def call_with_data @ctrl.call(*@data) end |
#to_s ⇒ Object
84 |
# File 'lib/carat/nack.rb', line 84 def to_s; "n/a"; end |