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

#countObject

Returns the value of attribute count

Returns:

  • (Object)

    the current value of count



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

def count
  @count
end

#indexObject

Returns the value of attribute index

Returns:

  • (Object)

    the current value of index



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

def index
  @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
# File 'lib/osctld/id_range/allocation_table.rb', line 4

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

Instance Method Details

#dumpObject



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

def dump
  Hash[to_h.map { |k,v| [k.to_s, v] }]
end

#exportObject



16
17
18
19
20
21
22
# File 'lib/osctld/id_range/allocation_table.rb', line 16

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

#last_indexObject



8
9
10
# File 'lib/osctld/id_range/allocation_table.rb', line 8

def last_index
  index + count - 1
end