Class: Explete
Overview
Save cognitive overhead by having this in the same file
Constant Summary collapse
- INFIX_SUBSTITUTIONS =
such performance.
['', '_'].freeze
Instance Attribute Summary collapse
-
#method ⇒ Object
Returns the value of attribute method.
-
#object ⇒ Object
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
- #find_real_method ⇒ Object
- #infix ⇒ Object
-
#infix_substitution ⇒ Object
like a pro.
- #possible_method_names ⇒ Object
- #target_method ⇒ Object
Instance Attribute Details
#method ⇒ Object
Returns the value of attribute method
14 15 16 |
# File 'lib/expletive_infixation/ext/object.rb', line 14 def method @method end |
#object ⇒ Object
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_method ⇒ Object
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 |
#infix ⇒ Object
25 26 27 |
# File 'lib/expletive_infixation/ext/object.rb', line 25 def infix ExpletiveInfixation.expletive_infix end |
#infix_substitution ⇒ Object
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_names ⇒ Object
33 34 35 |
# File 'lib/expletive_infixation/ext/object.rb', line 33 def possible_method_names INFIX_SUBSTITUTIONS.map &infix_substitution end |
#target_method ⇒ Object
21 22 23 |
# File 'lib/expletive_infixation/ext/object.rb', line 21 def target_method infix =~ method and find_real_method end |