Class: Camille::TypeError

Inherits:
Object
  • Object
show all
Defined in:
lib/camille/type_error.rb

Defined Under Namespace

Classes: ArgumentError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message = nil, **components) ⇒ TypeError

Returns a new instance of TypeError.



7
8
9
10
11
12
13
14
15
# File 'lib/camille/type_error.rb', line 7

def initialize message = nil, **components
  if message.is_a? String
    @message = message
  elsif !components.empty?
    @components = components
  else
    raise ArgumentError.new("Expecting one string or one hash.")
  end
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



5
6
7
# File 'lib/camille/type_error.rb', line 5

def components
  @components
end

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/camille/type_error.rb', line 5

def message
  @message
end

Instance Method Details

#basic?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/camille/type_error.rb', line 17

def basic?
  !!@message
end

#checked?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/camille/type_error.rb', line 31

def checked?
  false
end

#inspectObject



21
22
23
24
25
# File 'lib/camille/type_error.rb', line 21

def inspect
  string_io = StringIO.new
  Camille::TypeErrorPrinter.new(self).print string_io
  "#<Camille::TypeError\n#{string_io.string}>"
end

#to_sObject



27
28
29
# File 'lib/camille/type_error.rb', line 27

def to_s
  inspect
end

#type_error?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/camille/type_error.rb', line 35

def type_error?
  true
end