class SslLabs::Host

Constants

ATTRS

Public Class Methods

from_json(str) click to toggle source
# File lib/ssl_labs/host.rb, line 36
def self.from_json(str)
  json = JSON.parse(str)
  host = self.new
  json.each do |k, v|
    case sym = Util.underscore(k).to_sym
    when :cache_expiry_time
      host.cache_expiry_time = Time.at(v / 1000.0)
    when :start_time
      host.start_time = Time.at(v / 1000.0)
    when :test_time
      host.test_time = Time.at(v / 1000.0)
    when :endpoints
      host.endpoints = v.map { |ep| Endpoint.from_hash(ep) }
    when *ATTRS
      host.send("#{sym}=", v)
    else
      raise ArgumentError, "Unknown JSON key #{k.inspect} (#{sym.inspect})"
    end
  end
  host
end
new() click to toggle source
# File lib/ssl_labs/host.rb, line 32
def initialize
  @endpoints = []
end