Class: Retab::Partition

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/partitions/partition.rb

Constant Summary collapse

HASH_ATTRS =
{
  id: :id,
  file: :file,
  model: :model,
  key: :key,
  instructions: :instructions,
  n_consensus: :n_consensus,
  allow_overlap: :allow_overlap,
  output: :output,
  consensus: :consensus,
  usage: :usage,
  created_at: :created_at
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

#inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ Partition

Returns a new instance of Partition.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/retab/partitions/partition.rb', line 35

def initialize(json)
  hash = self.class.normalize(json)
  @id = hash[:id]
  @file = hash[:file] ? Retab::FileRef.new(hash[:file]) : nil
  @model = hash[:model]
  @key = hash[:key]
  @instructions = hash[:instructions]
  @n_consensus = hash[:n_consensus]
  @allow_overlap = hash[:allow_overlap]
  @output = (hash[:output] || []).map { |item| item ? Retab::PartitionChunk.new(item) : nil }
  @consensus = hash[:consensus] ? Retab::PartitionConsensus.new(hash[:consensus]) : nil
  @usage = hash[:usage] ? Retab::RetabUsage.new(hash[:usage]) : nil
  @created_at = hash[:created_at]
end

Instance Attribute Details

#allow_overlapObject

Returns the value of attribute allow_overlap.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def allow_overlap
  @allow_overlap
end

#consensusObject

Returns the value of attribute consensus.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def consensus
  @consensus
end

#created_atObject

Returns the value of attribute created_at.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def created_at
  @created_at
end

#fileObject

Returns the value of attribute file.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def file
  @file
end

#idObject

Returns the value of attribute id.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def id
  @id
end

#instructionsObject

Returns the value of attribute instructions.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def instructions
  @instructions
end

#keyObject

Returns the value of attribute key.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def key
  @key
end

#modelObject

Returns the value of attribute model.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def model
  @model
end

#n_consensusObject

Returns the value of attribute n_consensus.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def n_consensus
  @n_consensus
end

#outputObject

Returns the value of attribute output.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def output
  @output
end

#usageObject

Returns the value of attribute usage.



22
23
24
# File 'lib/retab/partitions/partition.rb', line 22

def usage
  @usage
end