Class: Daytona::Resources

Inherits:
Object
  • Object
show all
Defined in:
lib/daytona/common/resources.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cpu: nil, memory: nil, disk: nil, gpu: nil) ⇒ Resources

Returns a new instance of Resources.

Parameters:

  • cpu (Integer, nil) (defaults to: nil)

    Number of CPU cores to allocate

  • memory (Integer, nil) (defaults to: nil)

    Amount of memory in GiB to allocate

  • disk (Integer, nil) (defaults to: nil)

    Amount of disk space in GiB to allocate

  • gpu (Integer, nil) (defaults to: nil)

    Number of GPUs to allocate



21
22
23
24
25
26
# File 'lib/daytona/common/resources.rb', line 21

def initialize(cpu: nil, memory: nil, disk: nil, gpu: nil)
  @cpu = cpu
  @memory = memory
  @disk = disk
  @gpu = gpu
end

Instance Attribute Details

#cpuInteger? (readonly)

Returns Number of CPU cores to allocate.

Returns:

  • (Integer, nil)

    Number of CPU cores to allocate



6
7
8
# File 'lib/daytona/common/resources.rb', line 6

def cpu
  @cpu
end

#diskInteger? (readonly)

Returns Amount of disk space in GiB to allocate.

Returns:

  • (Integer, nil)

    Amount of disk space in GiB to allocate



12
13
14
# File 'lib/daytona/common/resources.rb', line 12

def disk
  @disk
end

#gpuInteger? (readonly)

Returns Number of GPUs to allocate.

Returns:

  • (Integer, nil)

    Number of GPUs to allocate



15
16
17
# File 'lib/daytona/common/resources.rb', line 15

def gpu
  @gpu
end

#memoryInteger? (readonly)

Returns Amount of memory in GiB to allocate.

Returns:

  • (Integer, nil)

    Amount of memory in GiB to allocate



9
10
11
# File 'lib/daytona/common/resources.rb', line 9

def memory
  @memory
end

Instance Method Details

#to_hHash

Returns Hash representation of the resources.

Returns:

  • (Hash)

    Hash representation of the resources



29
# File 'lib/daytona/common/resources.rb', line 29

def to_h = { cpu:, memory:, disk:, gpu: }.compact