Class: BomDB::Export::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/bomdb/export/result.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(success:, body: nil, error: nil) ⇒ Result

Returns a new instance of Result.



6
7
8
9
10
# File 'lib/bomdb/export/result.rb', line 6

def initialize(success:, body: nil, error: nil)
  @success = success
  @error = error
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



4
5
6
# File 'lib/bomdb/export/result.rb', line 4

def body
  @body
end

#errorObject (readonly)

Returns the value of attribute error.



4
5
6
# File 'lib/bomdb/export/result.rb', line 4

def error
  @error
end

#successObject (readonly)

Returns the value of attribute success.



4
5
6
# File 'lib/bomdb/export/result.rb', line 4

def success
  @success
end

Instance Method Details

#messageObject



20
21
22
23
24
25
26
# File 'lib/bomdb/export/result.rb', line 20

def message
  if @success
    "Succeeded"
  else
    @error.to_s
  end
end

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/bomdb/export/result.rb', line 12

def success?
  @success
end

#to_sObject



16
17
18
# File 'lib/bomdb/export/result.rb', line 16

def to_s
  @body
end