Top Level Namespace

Defined Under Namespace

Classes: Method_Name

Instance Method Summary collapse

Instance Method Details

#Method_Name(name) ⇒ Object

def Method_Name



26
27
28
29
30
31
32
33
34
# File 'lib/Method_Name.rb', line 26

def Method_Name name
  
  new_name = File.basename(name.strip.downcase)
  .gsub( %r!#{Method_Name::INVALID_REGEXP}+!, '_' )

  return nil unless Method_Name?(new_name)
  new_name
  
end

#Method_Name?(raw_name) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/Method_Name.rb', line 3

def Method_Name? raw_name
  name = raw_name.to_s
  return false if name[' ']
  return false if name.to_s.strip.empty?
  return true unless name[Method_Name::INVALID_REGEXP]
  
  begin
    eval %!
      class Method_Name
        module Sandbox
          def #{name}
          end
        end
      end
    !

    true
  rescue Object => e
    false
  end

end