class NOAA_SOAP

Attributes

client[R]

Public Class Methods

most_recent(data, count = 1) click to toggle source
# File lib/noaa_soap.rb, line 6
def self.most_recent(data, count = 1)
        rtn = []
        d = data.sort { |x,y| y[:time_stamp] <=> x[:time_stamp] }
        
        (1..count).each do |i|
                rtn << d[i - 1]
        end
        rtn
end
new(wsdl) click to toggle source
# File lib/noaa_soap.rb, line 16
def initialize(wsdl)
        create_client(wsdl)
end

Public Instance Methods

pull_response(operation, message = nil) click to toggle source
# File lib/noaa_soap.rb, line 20
def pull_response(operation, message = nil)
        if !!message          
                response = self.client.call(operation, message: message)
        else
                response = self.client.call(operation)
        end

        response
rescue Savon::SOAPFault => error
    fault_code = error.to_hash[:fault][:faultcode]
    raise CustomError, fault_code
end

Private Instance Methods

create_client(wsdl) click to toggle source
# File lib/noaa_soap.rb, line 34
def create_client(wsdl)
        client = Savon.client(wsdl: wsdl, \
                        open_timeout: 30, \
                        read_timeout: 30, \
                        log: false, \
                        follow_redirects: true)

        @client = client
        self.client
end