Class: Ettin::MethodName

Inherits:
Object
  • Object
show all
Defined in:
lib/ettin/method_name.rb

Overview

A class for analyzing and manipulating a method's name

Constant Summary collapse

ASSIGN_CHAR =
"="
BANG_CHAR =
"!"

Instance Method Summary collapse

Constructor Details

#initialize(method) ⇒ MethodName


10
11
12
# File 'lib/ettin/method_name.rb', line 10

def initialize(method)
  @method = method.to_s
end

Instance Method Details

#assignment?Boolean


34
35
36
# File 'lib/ettin/method_name.rb', line 34

def assignment?
  method[-1] == ASSIGN_CHAR
end

#bang?Boolean


30
31
32
# File 'lib/ettin/method_name.rb', line 30

def bang?
  method[-1] == BANG_CHAR
end

#cleanObject


22
23
24
25
26
27
28
# File 'lib/ettin/method_name.rb', line 22

def clean
  @clean ||= if bang? || assignment?
    method.chop
  else
    method
  end.to_sym
end

#to_sObject


18
19
20
# File 'lib/ettin/method_name.rb', line 18

def to_s
  method
end

#to_symObject


14
15
16
# File 'lib/ettin/method_name.rb', line 14

def to_sym
  method.to_sym
end