Exception: StandardError

Inherits:
Exception
  • Object
show all
Defined in:
lib/ugh.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 short_message = 'unspecified ugh', **attributes
  super short_message
  @short_message = short_message
  @attributes = attributes
  return
end

Instance Attribute Details

#attributesObject

Returns the value of attribute attributes.



10
11
12
# File 'lib/ugh.rb', line 10

def attributes
  @attributes
end

#short_messageObject

Returns the value of attribute short_message.



9
10
11
# File 'lib/ugh.rb', line 9

def short_message
  @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

#inspectObject



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