class SslLabs::EndpointData::Details

Constants

ATTRS

Public Class Methods

from_hash(hash) click to toggle source
# File lib/ssl_labs/endpoint_data/details.rb, line 52
def self.from_hash(hash)
  details = self.new
  hash.each do |k, v|
    case sym = Util.underscore(k).to_sym
    when :cert
      details.cert = Cert.from_hash(v)
    when :chain
      details.chain = Chain.from_hash(v)
    when :host_start_time
      details.host_start_time = Time.at(v / 1000.0)
    when :key
      details.key = Key.from_hash(v)
    when :npn_protocols
      details.npn_protocols = v.split
    when :protocols
      details.protocols = v['list'].map { |hash| Protocol.from_hash(hash) }
    when :sims
      details.sims = v['results'].map { |hash| Sim.from_hash(hash) }
    when :suites
      details.suites = Suites.from_hash(v)
    when *ATTRS
      details.send("#{sym}=", v)
    else
      raise ArgumentError, "Unknown key #{k.inspect} (#{sym.inspect})"
    end
  end
  details
end