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.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/mega/nack.rb', line 67 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
101 102 103 |
# File 'lib/mega/nack.rb', line 101 def method_missing(meth, *args) raise_error end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
65 66 67 |
# File 'lib/mega/nack.rb', line 65 def data @data end |
#error ⇒ Object (readonly)
Returns the value of attribute error.
65 66 67 |
# File 'lib/mega/nack.rb', line 65 def error @error end |
Instance Method Details
#call(*args) ⇒ Object
83 84 85 |
# File 'lib/mega/nack.rb', line 83 def call(*args) @ctrl.call(*args) end |
#call_with_data ⇒ Object
87 88 89 |
# File 'lib/mega/nack.rb', line 87 def call_with_data @ctrl.call(*@data) end |
#to_s ⇒ Object
95 |
# File 'lib/mega/nack.rb', line 95 def to_s; "n/a"; end |