class SslLabs::EndpointData::Details::Cert

Constants

ATTRS

Public Class Methods

from_hash(hash) click to toggle source
# File lib/ssl_labs/endpoint_data/details/cert.rb, line 31
def self.from_hash(hash)
  cert = self.new
  hash.each do |k, v|
    case sym = Util.underscore(k).to_sym
    when :crl_ur_is
      cert.crl_uris = v
    when :not_after
      cert.not_after = Time.at(v / 1000.0)
    when :not_before
      cert.not_before = Time.at(v / 1000.0)
    when :ocsp_ur_is
      cert.ocsp_uris = v
    when *ATTRS
      cert.send("#{sym}=", v)
    else
      raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
    end
  end
  cert
end