Exception: StandardError
- Inherits:
-
Exception
- Object
- Exception
- StandardError
- Defined in:
- lib/ugh.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#short_message ⇒ Object
Returns the value of attribute short_message.
Instance Method Summary collapse
- #[](name) ⇒ Object
- #[]=(name, value) ⇒ Object
-
#initialize(short_message = 'unspecified ugh', **attributes) ⇒ StandardError
constructor
A new instance of StandardError.
- #inspect ⇒ Object
- #to_s(attributes_in_parentheses: true) ⇒ Object
Constructor Details
#initialize(short_message = 'unspecified ugh', **attributes) ⇒ StandardError
Returns a new instance of StandardError.
2 3 4 5 6 7 |
# File 'lib/ugh.rb', line 2 def initialize = 'unspecified ugh', **attributes super @short_message = @attributes = attributes return end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
10 11 12 |
# File 'lib/ugh.rb', line 10 def attributes @attributes end |
#short_message ⇒ Object
Returns the value of attribute short_message.
9 10 11 |
# File 'lib/ugh.rb', line 9 def @short_message end |
Instance Method Details
#[](name) ⇒ Object
33 34 35 |
# File 'lib/ugh.rb', line 33 def [] name return @attributes[name.to_sym] end |
#[]=(name, value) ⇒ Object
37 38 39 |
# File 'lib/ugh.rb', line 37 def []= name, value return @attributes[name.to_sym] = value end |
#inspect ⇒ Object
29 30 31 |
# File 'lib/ugh.rb', line 29 def inspect return '#<' + to_s(attributes_in_parentheses: false) + '>' end |
#to_s(attributes_in_parentheses: true) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ugh.rb', line 12 def to_s attributes_in_parentheses: true s = '' << @short_message firstp = true @attributes.each_pair do |name, value| if firstp then s << (attributes_in_parentheses ? ' (' : ', ') firstp = false else s << ', ' end firstp = false s << name.to_s << ': ' << value.inspect end s << ')' if attributes_in_parentheses and !firstp return s end |