Class: Bsdkrun::NetworkInfo

Inherits:
Data
  • Object
show all
Defined in:
lib/bsdkrun/types.rb

Overview

A global network as reported by bsdkrun network ls --json.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def created_at
  @created_at
end

#gatewayObject (readonly)

Returns the value of attribute gateway

Returns:

  • (Object)

    the current value of gateway



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def gateway
  @gateway
end

#membersObject (readonly)

Returns the value of attribute members

Returns:

  • (Object)

    the current value of members



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def members
  @members
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def name
  @name
end

#runningObject (readonly)

Returns the value of attribute running

Returns:

  • (Object)

    the current value of running



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def running
  @running
end

#subnetObject (readonly)

Returns the value of attribute subnet

Returns:

  • (Object)

    the current value of subnet



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def subnet
  @subnet
end

#upObject (readonly)

Returns the value of attribute up

Returns:

  • (Object)

    the current value of up



84
85
86
# File 'lib/bsdkrun/types.rb', line 84

def up
  @up
end

Class Method Details

.from_row(row) ⇒ NetworkInfo

Parameters:

  • row (Hash)

Returns:



87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/bsdkrun/types.rb', line 87

def self.from_row(row)
  created = row["created_at"]
  new(
    name: row["name"].to_s,
    subnet: row["subnet"].to_s,
    gateway: row["gateway"].to_s,
    members: (row["members"] || 0).to_i,
    running: (row["running"] || 0).to_i,
    up: !!row["up"],
    created_at: created.nil? ? nil : created.to_i
  )
end