Class: String

Inherits:
Object show all
Defined in:
lib/extensions/string_extensions.rb

Instance Method Summary collapse

Instance Method Details

#class_nameObject



6
7
8
9
10
# File 'lib/extensions/string_extensions.rb', line 6

def class_name
  name = self.split("::")[-1..-1]
  name = name[0] if name.kind_of? Array 
  name
end

#in_module?(module_name) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/extensions/string_extensions.rb', line 12

def in_module?(module_name)
  modules = self.modules
  modules.include?(module_name)      
end

#modulesObject



2
3
4
# File 'lib/extensions/string_extensions.rb', line 2

def modules
  self.split("::")[0..-2]
end

#rule_listObject



17
18
19
# File 'lib/extensions/string_extensions.rb', line 17

def rule_list  
  self.split_names 
end

#rulesObject

return name matching rules as array split “ ”, “,”



32
33
# File 'lib/extensions/string_extensions.rb', line 32

def rules
end

#split_namesObject



21
22
23
24
25
26
27
28
# File 'lib/extensions/string_extensions.rb', line 21

def split_names
  if self.include?(",")
    s = self.gsub(/\s/, '')
    s.split(",") if s
  else
    self.split(" ")
  end
end