Sha256: e5cb8cde7c486b074d516f7328ca209b4f434d1a8463ba898fb25355edb0c2b5

Contents?: true

Size: 1.36 KB

Versions: 14

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

# CaseFixture.java, containing an actual and specific combination of variables.
class RastSpec
  # token_converter is the mapping of a variable token to a converter
  # converters is a list of converters used via positional tokens.
  attr_reader :variables, :pair, :pair_reversed, :rule, :description,
              :exclude_clause, :token_converter, :converters

  attr_accessor :exclude

  def initialize(description: '', variables: [][], rule: nil)
    @description = description
    @variables = variables
    @pair = {}
    @pair_reversed = {}
    @rule = rule
    @exclude_clause = nil
  end

  def init_pair(pair_config: {})
    @pair[pair_config.keys.first.to_s] = pair_config.values.first.to_s

    array = [@pair.to_a.first.reverse].first
    @pair_reversed = { array.first.to_s => array.last }
    self
  end

  def init_converters(converters: [])
    @converters = converters
    @token_converter = {}

    @variables.keys.each_with_index do |key, index|
      @variables[key].each do |element|
        @token_converter[element.to_s] = converters[index]
      end
    end

    self
  end

  def init_exclusion(exclude_clause)
    @exclude_clause = exclude_clause
    self
  end

  def to_s
    "Class: #{self.class}
Description: #{@description}
Variables: #{@variables}
Rules: #{@rules}
Pair: #{@pair}
Converters: #{@converters}
    "
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rast-0.14.0 lib/rast/rast_spec.rb
rast-0.11.4 lib/rast/rast_spec.rb
rast-0.11.3 lib/rast/rast_spec.rb
rast-0.11.1 lib/rast/rast_spec.rb
rast-0.11.0 lib/rast/rast_spec.rb
rast-0.10.0 lib/rast/rast_spec.rb
rast-0.9.0 lib/rast/rast_spec.rb
rast-0.9.0.pre lib/rast/rast_spec.rb
rast-0.8.1.pre lib/rast/rast_spec.rb
rast-0.8.0.pre lib/rast/rast_spec.rb
rast-0.6.2.pre lib/rast/rast_spec.rb
rast-0.6.1.pre lib/rast/rast_spec.rb
rast-0.6.0.pre lib/rast/rast_spec.rb
rast-0.4.2.pre lib/rast/rast_spec.rb