Class: Linguistics::Latin::Verb::LatinVerb::DynamicMethodResolver
- Inherits:
-
Object
- Object
- Linguistics::Latin::Verb::LatinVerb::DynamicMethodResolver
- Defined in:
- lib/latinverb/dynamic_method_resolver.rb
Instance Method Summary collapse
- #apply! ⇒ Object
- #components ⇒ Object
-
#initialize(verb, method_name) ⇒ DynamicMethodResolver
constructor
A new instance of DynamicMethodResolver.
- #supported_method? ⇒ Boolean
- #tense_method ⇒ Object
- #vector_specifier ⇒ Object
Constructor Details
#initialize(verb, method_name) ⇒ DynamicMethodResolver
Returns a new instance of DynamicMethodResolver.
6 7 8 9 |
# File 'lib/latinverb/dynamic_method_resolver.rb', line 6 def initialize(verb, method_name) @verb = verb @method_name = method_name.to_s end |
Instance Method Details
#apply! ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/latinverb/dynamic_method_resolver.rb', line 27 def apply! if @verb.respond_to?(tense_method.to_sym) tense_block = @verb.send(tense_method.to_sym) return false if tense_block.nil? tense_block.send(vector_specifier.to_sym) else false end end |
#components ⇒ Object
11 12 13 |
# File 'lib/latinverb/dynamic_method_resolver.rb', line 11 def components @method_name.split('_') end |
#supported_method? ⇒ Boolean
23 24 25 |
# File 'lib/latinverb/dynamic_method_resolver.rb', line 23 def supported_method? !(tense_method.nil? || vector_specifier.nil?) && @method_name.match(/_/) end |
#tense_method ⇒ Object
15 16 17 |
# File 'lib/latinverb/dynamic_method_resolver.rb', line 15 def tense_method Array(components[0..5]).join('_') end |
#vector_specifier ⇒ Object
19 20 21 |
# File 'lib/latinverb/dynamic_method_resolver.rb', line 19 def vector_specifier Array(components[6..-1]).join('_') end |