Class: Flexus::RulesCollection

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/flexus/rules_collection.rb

Overview

Wraps inflections array

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ RulesCollection

Returns a new instance of RulesCollection.



11
12
13
# File 'lib/flexus/rules_collection.rb', line 11

def initialize(*args)
  @collection = Array.new(*args)
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
# File 'lib/flexus/rules_collection.rb', line 30

def ==(other)
  @collection == other.to_a
end

#apply_to(word) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Applies first found rule to given word

Parameters:

  • word (String)

Returns:

  • (String)

    modified word



24
25
26
27
28
# File 'lib/flexus/rules_collection.rb', line 24

def apply_to(word)
  result = word.dup
  each { |rule, replacement| break if result.gsub!(rule, replacement) }
  result
end

#to_aObject



34
35
36
# File 'lib/flexus/rules_collection.rb', line 34

def to_a
  @collection.dup
end