Class: Bridgetown::Inflector

Inherits:
Dry::Inflector
  • Object
show all
Defined in:
bridgetown-core/lib/bridgetown-core/inflector.rb

Instance Method Summary collapse

Constructor Details

#initializeInflector

rubocop:disable Lint/MissingSuper



7
8
9
10
11
12
13
14
# File 'bridgetown-core/lib/bridgetown-core/inflector.rb', line 7

def initialize(&) # rubocop:disable Lint/MissingSuper
  @inflections = Dry::Inflector::Inflections.build do |inflections|
    inflections.acronym "HTML"
    inflections.acronym "CSS"
    inflections.acronym "JS"
  end
  configure(&) if block_given?
end

Instance Method Details

#==(other) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'bridgetown-core/lib/bridgetown-core/inflector.rb', line 30

def ==(other)
  return super unless other.is_a?(Bridgetown::Inflector)

  # NOTE: strictly speaking, this might be wrong if two inflector instances have different
  # rule sets…but as this equality check is mainly done within the automated test suite, we
  # just assume two instances are equal. No production apps will need multiple,
  # differently-configured inflectors running at once ;)
  true
end

#camelize(basename) ⇒ Object

for compatibility with Zeitwerk



21
22
23
# File 'bridgetown-core/lib/bridgetown-core/inflector.rb', line 21

def camelize(basename, *)
  super(basename)
end

#configure {|inflections| ... } ⇒ Object

Yields:

  • (inflections)


16
17
18
# File 'bridgetown-core/lib/bridgetown-core/inflector.rb', line 16

def configure
  yield inflections
end

#to_sObject Also known as: inspect



25
26
27
# File 'bridgetown-core/lib/bridgetown-core/inflector.rb', line 25

def to_s
  "#<Bridgetown::Inflector>"
end