Class: Ibex::GrammarTests::ProductionCoverage

Inherits:
Struct
  • Object
show all
Defined in:
lib/ibex/grammar_tests.rb,
lib/ibex/grammar_tests.rb,
sig/ibex/grammar_tests.rbs,
sig/ibex/grammar_tests.rbs

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#covered_idsObject

Returns the value of attribute covered_ids

Returns:

  • (Object)

    the current value of covered_ids



30
31
32
# File 'lib/ibex/grammar_tests.rb', line 30

def covered_ids
  @covered_ids
end

#missing_idsObject

Returns the value of attribute missing_ids

Returns:

  • (Object)

    the current value of missing_ids



30
31
32
# File 'lib/ibex/grammar_tests.rb', line 30

def missing_ids
  @missing_ids
end

#production_countObject

Returns the value of attribute production_count

Returns:

  • (Object)

    the current value of production_count



30
31
32
# File 'lib/ibex/grammar_tests.rb', line 30

def production_count
  @production_count
end

Class Method Details

.new(covered_ids:, missing_ids:, production_count:) ⇒ instance .new(arg0) ⇒ instance

Overloads:

  • .new(covered_ids:, missing_ids:, production_count:) ⇒ instance

    Parameters:

    • covered_ids: (Array[Integer])
    • missing_ids: (Array[Integer])
    • production_count: (Integer)

    Returns:

    • (instance)
  • .new(arg0) ⇒ instance

    Parameters:

    • arg0 ({ ?covered_ids: Array[Integer], ?missing_ids: Array[Integer], ?production_count: Integer })

    Returns:

    • (instance)


39
40
# File 'sig/ibex/grammar_tests.rbs', line 39

def self.new: (?covered_ids: Array[Integer], ?missing_ids: Array[Integer], ?production_count: Integer) -> instance
| ({ ?covered_ids: Array[Integer], ?missing_ids: Array[Integer], ?production_count: Integer }) -> instance

Instance Method Details

#complete?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


51
# File 'lib/ibex/grammar_tests.rb', line 51

def complete? = missing_ids.empty?

#meets?(minimum) ⇒ Boolean

RBS:

  • (Integer minimum) -> bool

Parameters:

  • minimum (Integer)

Returns:

  • (Boolean)


46
47
48
# File 'lib/ibex/grammar_tests.rb', line 46

def meets?(minimum)
  covered_ids.length * 100 >= production_count * minimum
end

#percentageFloat

RBS:

  • () -> Float

Returns:

  • (Float)


39
40
41
42
43
# File 'lib/ibex/grammar_tests.rb', line 39

def percentage
  return 100.0 if production_count.zero?

  covered_ids.length.fdiv(production_count) * 100
end