Class: Masklen::Network

Inherits:
Struct
  • Object
show all
Defined in:
lib/masklen/types.rb

Overview

Network and ASN data for an IP address.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#asnObject

Returns the value of attribute asn

Returns:

  • (Object)

    the current value of asn



32
33
34
# File 'lib/masklen/types.rb', line 32

def asn
  @asn
end

#domainObject

Returns the value of attribute domain

Returns:

  • (Object)

    the current value of domain



32
33
34
# File 'lib/masklen/types.rb', line 32

def domain
  @domain
end

#ispObject

Returns the value of attribute isp

Returns:

  • (Object)

    the current value of isp



32
33
34
# File 'lib/masklen/types.rb', line 32

def isp
  @isp
end

#organizationObject

Returns the value of attribute organization

Returns:

  • (Object)

    the current value of organization



32
33
34
# File 'lib/masklen/types.rb', line 32

def organization
  @organization
end

Class Method Details

.from_hash(hash) ⇒ Object

Build a Network from a parsed JSON hash. Returns nil if hash is nil.



40
41
42
43
44
45
46
47
48
49
# File 'lib/masklen/types.rb', line 40

def self.from_hash(hash)
  return nil if hash.nil?

  new(
    asn:          hash["asn"],
    isp:          hash["isp"],
    organization: hash["organization"],
    domain:       hash["domain"]
  )
end