Class: Codinginfo::Variant

Inherits:
Object show all
Defined in:
lib/codinginfo.rb

Instance Method Summary collapse

Constructor Details

#initialize(headers, row) ⇒ Variant

Returns a new instance of Variant.



53
54
55
# File 'lib/codinginfo.rb', line 53

def initialize(headers, row)
  @properties = headers.zip(row).to_h
end

Instance Method Details

#attributesObject



63
64
65
66
67
68
# File 'lib/codinginfo.rb', line 63

def attributes
  @attrs ||= @properties
    .reject { |key, _| key.start_with?("CSIG_") }
    .reject { |key, _| key.start_with?("CVAR_") }
    .select { |_, val| val == 0 || val == 1 || val == "-" }
end

#cvarsObject



57
58
59
60
61
# File 'lib/codinginfo.rb', line 57

def cvars
  @cvars ||= @properties
    .select { |key, _| key.start_with?("CVAR_") }
    .map { Cvar.new(name: _1, value: _2.to_i) }
end

#descriptionObject



74
# File 'lib/codinginfo.rb', line 74

def description = @properties[:swfk_id]

#has_matching_cvar?(label) ⇒ Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/codinginfo.rb', line 70

def has_matching_cvar?(label)
  cvars.any? { _1.match?(label) }
end