Class: String

Inherits:
Object
  • Object
show all
Defined in:
lib/danger/core_ext/string.rb

Instance Method Summary collapse

Instance Method Details

#danger_classObject


2
3
4
# File 'lib/danger/core_ext/string.rb', line 2

def danger_class
  split("_").collect!(&:capitalize).join
end

#danger_pluralize(count) ⇒ Object


6
7
8
# File 'lib/danger/core_ext/string.rb', line 6

def danger_pluralize(count)
  "#{count} #{self}#{'s' unless count == 1}"
end

#danger_underscoreObject


10
11
12
13
14
15
16
# File 'lib/danger/core_ext/string.rb', line 10

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