Class: Valigator::CSV::Error

Inherits:
Object
  • Object
show all
Defined in:
lib/valigator/csv/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(error) ⇒ Error

Returns a new instance of Error.



13
14
15
16
17
18
19
20
# File 'lib/valigator/csv/error.rb', line 13

def initialize(error)
  case error
    when Hash
      build_from_hash error
    when StandardError
      build_from_error error
  end
end

Instance Attribute Details

#detailsObject (readonly)

Returns the value of attribute details.



11
12
13
# File 'lib/valigator/csv/error.rb', line 11

def details
  @details
end

#fieldObject (readonly)

Returns the value of attribute field.



11
12
13
# File 'lib/valigator/csv/error.rb', line 11

def field
  @field
end

#messageObject (readonly)

Returns the value of attribute message.



11
12
13
# File 'lib/valigator/csv/error.rb', line 11

def message
  @message
end

#rowObject (readonly)

Returns the value of attribute row.



11
12
13
# File 'lib/valigator/csv/error.rb', line 11

def row
  @row
end

#typeObject (readonly)

Returns the value of attribute type.



11
12
13
# File 'lib/valigator/csv/error.rb', line 11

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



22
23
24
# File 'lib/valigator/csv/error.rb', line 22

def ==(other)
  row == other.row && message == other.message && type == other.type && field == other.field && details == other.details
end

#to_hashObject



26
27
28
29
30
31
32
33
34
# File 'lib/valigator/csv/error.rb', line 26

def to_hash
  {
    row: row,
    type: type,
    message: message,
    field: field,
    details: details
  }
end