Class: Copyleaks::CopyleaksAiImageDetectionResultModel

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb

Overview

RLE-encoded mask data for AI-detected regions.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(starts: nil, lengths: nil) ⇒ CopyleaksAiImageDetectionResultModel

Initialize a new CopyleaksAiImageDetectionResultModel

Parameters:

  • starts (Array<Integer>) (defaults to: nil)

    Start positions of AI-detected segments in the flattened image array

  • lengths (Array<Integer>) (defaults to: nil)

    Lengths of AI-detected segments corresponding to each start position



40
41
42
43
# File 'lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb', line 40

def initialize(starts: nil, lengths: nil)
  @starts = starts
  @lengths = lengths
end

Instance Attribute Details

#lengthsObject

Lengths of AI-detected segments corresponding to each start position.



34
35
36
# File 'lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb', line 34

def lengths
  @lengths
end

#startsObject

Start positions of AI-detected segments in the flattened image array.



31
32
33
# File 'lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb', line 31

def starts
  @starts
end

Class Method Details

.from_json(json_hash) ⇒ Object

Create instance from JSON hash



46
47
48
49
50
51
52
53
# File 'lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb', line 46

def self.from_json(json_hash)
  return nil if json_hash.nil?

  new(
    starts: json_hash['starts'],
    lengths: json_hash['lengths']
  )
end

Instance Method Details

#to_json(*args) ⇒ Object

Convert to JSON



56
57
58
59
60
61
# File 'lib/copyleaks/models/imageDetection/responses/CopyleaksAiImageDetectionResultModel.rb', line 56

def to_json(*args)
  {
    'starts' => @starts,
    'lengths' => @lengths
  }.to_json(*args)
end