Class: NackClass
Instance Attribute Summary collapse
Instance Method Summary
collapse
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
Returns the value of attribute data.
54
55
56
|
# File 'lib/carat/nack.rb', line 54
def data
@data
end
|
Returns the value of attribute error.
54
55
56
|
# File 'lib/carat/nack.rb', line 54
def error
@error
end
|
Instance Method Details
86
87
88
|
# File 'lib/carat/nack.rb', line 86
def ==(x)
x.is_a?(NackClass)
end
|
#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
|
#raise_error ⇒ Object
80
81
82
|
# File 'lib/carat/nack.rb', line 80
def raise_error
raise @error
end
|
84
|
# File 'lib/carat/nack.rb', line 84
def to_s; "n/a"; end
|