Class: Explete

Inherits:
Struct show all
Defined in:
lib/expletive_infixation/ext/object.rb

Overview

Save cognitive overhead by having this in the same file

Constant Summary collapse

INFIX_SUBSTITUTIONS =

such performance.

['', '_'].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#methodObject

Returns the value of attribute method



14
15
16
# File 'lib/expletive_infixation/ext/object.rb', line 14

def method
  @method
end

#objectObject

Returns the value of attribute object



14
15
16
# File 'lib/expletive_infixation/ext/object.rb', line 14

def object
  @object
end

Class Method Details

.target_method(*args) ⇒ Object



17
18
19
# File 'lib/expletive_infixation/ext/object.rb', line 17

def self.target_method(*args)
  new(*args).target_method
end

Instance Method Details

#find_real_methodObject



29
30
31
# File 'lib/expletive_infixation/ext/object.rb', line 29

def find_real_method
  possible_method_names.find { |m| object.respond_to? m }
end

#infixObject



25
26
27
# File 'lib/expletive_infixation/ext/object.rb', line 25

def infix
  ExpletiveInfixation.expletive_infix
end

#infix_substitutionObject

like a pro.



38
39
40
# File 'lib/expletive_infixation/ext/object.rb', line 38

def infix_substitution
  -> (substitution) { method.to_s.gsub infix, substitution }
end

#possible_method_namesObject



33
34
35
# File 'lib/expletive_infixation/ext/object.rb', line 33

def possible_method_names
  INFIX_SUBSTITUTIONS.map &infix_substitution
end

#target_methodObject



21
22
23
# File 'lib/expletive_infixation/ext/object.rb', line 21

def target_method
  infix =~ method and find_real_method
end