Class: OsCtld::IdRange::AllocationTable::Allocation

Inherits:
Struct
  • Object
show all
Defined in:
lib/osctld/id_range/allocation_table.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#block_countObject

Returns the value of attribute block_count

Returns:

  • (Object)

    the current value of block_count



3
4
5
# File 'lib/osctld/id_range/allocation_table.rb', line 3

def block_count
  @block_count
end

#block_indexObject

Returns the value of attribute block_index

Returns:

  • (Object)

    the current value of block_index



3
4
5
# File 'lib/osctld/id_range/allocation_table.rb', line 3

def block_index
  @block_index
end

#ownerObject

Returns the value of attribute owner

Returns:

  • (Object)

    the current value of owner



3
4
5
# File 'lib/osctld/id_range/allocation_table.rb', line 3

def owner
  @owner
end

Class Method Details

.load(data) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/osctld/id_range/allocation_table.rb', line 4

def self.load(data)
  new(
    data.fetch('block_index', data['index']),
    data.fetch('block_count', data['count']),
    data['owner']
  )
end

Instance Method Details

#dumpObject



16
17
18
# File 'lib/osctld/id_range/allocation_table.rb', line 16

def dump
  to_h.transform_keys(&:to_s)
end

#exportObject



20
21
22
23
24
25
26
# File 'lib/osctld/id_range/allocation_table.rb', line 20

def export
  {
    block_index:,
    block_count:,
    owner:
  }
end

#last_indexObject



12
13
14
# File 'lib/osctld/id_range/allocation_table.rb', line 12

def last_index
  block_index + block_count - 1
end