Class: Codinginfo::Variant
Instance Method Summary collapse
- #attributes ⇒ Object
- #cvars ⇒ Object
- #description ⇒ Object
- #has_matching_cvar?(label) ⇒ Boolean
-
#initialize(headers, row) ⇒ Variant
constructor
A new instance of Variant.
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
#attributes ⇒ Object
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 |
#cvars ⇒ Object
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 |
#description ⇒ Object
74 |
# File 'lib/codinginfo.rb', line 74 def description = @properties[:swfk_id] |
#has_matching_cvar?(label) ⇒ Boolean
70 71 72 |
# File 'lib/codinginfo.rb', line 70 def has_matching_cvar?(label) cvars.any? { _1.match?(label) } end |