Class: OsCtl::Lib::IdMap::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/libosctl/id_map.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#host_idObject

Returns the value of attribute host_id

Returns:

  • (Object)

    the current value of host_id



4
5
6
# File 'lib/libosctl/id_map.rb', line 4

def host_id
  @host_id
end

#id_countObject

Returns the value of attribute id_count

Returns:

  • (Object)

    the current value of id_count



4
5
6
# File 'lib/libosctl/id_map.rb', line 4

def id_count
  @id_count
end

#ns_idObject

Returns the value of attribute ns_id

Returns:

  • (Object)

    the current value of ns_id



4
5
6
# File 'lib/libosctl/id_map.rb', line 4

def ns_id
  @ns_id
end

Class Method Details

.from_hash(hash) ⇒ Object



10
11
12
# File 'lib/libosctl/id_map.rb', line 10

def self.from_hash(hash)
  Entry.new(hash[:ns_id], hash[:host_id], hash[:id_count])
end

.from_string(str, separator: ':') ⇒ Object



5
6
7
8
# File 'lib/libosctl/id_map.rb', line 5

def self.from_string(str, separator: ':')
  ns_id, host_id, cnt = str.split(separator)
  Entry.new(ns_id.to_i, host_id.to_i, cnt.to_i)
end

Instance Method Details

#to_aObject



14
15
16
# File 'lib/libosctl/id_map.rb', line 14

def to_a
  [ns_id, host_id, id_count]
end

#to_sObject



18
19
20
# File 'lib/libosctl/id_map.rb', line 18

def to_s
  "#{ns_id}:#{host_id}:#{id_count}"
end