Class: OFX::Status

Inherits:
Object
  • Object
show all
Defined in:
lib/ofx/status.rb,
lib/ofx/status.rb,
lib/ofx/1.0.2/status.rb

Overview

build tables of the status subclasses

Direct Known Subclasses

Error, Information, Warning

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code, severity, message) ⇒ Status

Returns a new instance of Status.



24
25
26
27
28
# File 'lib/ofx/status.rb', line 24

def initialize(code, severity, message)
    @code = code
    @severity = severity
    @message = message
end

Instance Attribute Details

#codeObject

Returns the value of attribute code.



20
21
22
# File 'lib/ofx/status.rb', line 20

def code
  @code
end

#messageObject

Returns the value of attribute message.



22
23
24
# File 'lib/ofx/status.rb', line 22

def message
  @message
end

#severityObject

Returns the value of attribute severity.



21
22
23
# File 'lib/ofx/status.rb', line 21

def severity
  @severity
end

Class Method Details

.from_numerical_code_severity_and_message(code, severity, message) ⇒ Object



30
31
32
33
34
35
# File 'lib/ofx/status.rb', line 30

def self.from_numerical_code_severity_and_message(code, severity, message)
    status_class = CODES_TO_OFX_STATUS[code] || SEVERITIES_TO_UNKNOWN_OFX_STATUS[severity]
    raise unless status_class
    
    status_class.new(code, severity, message)
end

.from_ofx_102_hash(status_hash) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/ofx/1.0.2/status.rb', line 20

def self.from_ofx_102_hash(status_hash)
    return OFX::Status.from_numerical_code_severity_and_message(status_hash['CODE'].to_i,
                                                                case status_hash['SEVERITY']
                                                                    when 'INFO' then :information
                                                                    when 'WARN' then :warning
                                                                    when 'ERROR' then :error
                                                                end,
                                                                status_hash['MESSAGE'])
end