Module: Eavi::VisitMethodHelper

Defined in:
lib/eavi/visit_method_helper.rb

Overview

Helper for visit methods generation, matching & co.

Constant Summary collapse

TEMPLATE =
'visit[%s]'.freeze
REGEXP =
/^visit\[(.*)\]$/

Class Method Summary collapse

Class Method Details

.gen_name(type) ⇒ Object

Return a visit method name for the type type.



8
9
10
# File 'lib/eavi/visit_method_helper.rb', line 8

def self.gen_name(type)
  return TEMPLATE % type.name
end

.get_type(visit_method) ⇒ Object

Return the type matching a visit method.



19
20
21
22
# File 'lib/eavi/visit_method_helper.rb', line 19

def self.get_type(visit_method)
  type_symbol = match(visit_method).captures[0]
  return const_get(type_symbol)
end

.match(visit_method_name) ⇒ Object

Return true if the visit_method_name is a well formed visit method name, else false.



14
15
16
# File 'lib/eavi/visit_method_helper.rb', line 14

def self.match(visit_method_name)
  return REGEXP.match(visit_method_name)
end