Module: OpenDsl::StringHelpers

Included in:
Context
Defined in:
lib/open_dsl/string_helpers.rb

Instance Method Summary collapse

Instance Method Details

#attribute_name(const_name) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/open_dsl/string_helpers.rb', line 8

def attribute_name(const_name)
  const_name.to_s.gsub(/::/, '/').
  gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
  gsub(/([a-z\d])([A-Z])/,'\1_\2').
  tr("-", "_").
  downcase
end

#constant_or_constant_name?(str_or_class) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
# File 'lib/open_dsl/string_helpers.rb', line 3

def constant_or_constant_name?(str_or_class)
  return true if str_or_class.is_a?(Class)
  !!(str_or_class.to_s =~ /^[A-Z]/)
end

#plural?(str) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/open_dsl/string_helpers.rb', line 16

def plural?(str)
  !!(str.to_s =~ /s$/)
end