Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/passwordstate/util.rb
Instance Method Summary collapse
Instance Method Details
#camel_case ⇒ Object
21 22 23 |
# File 'lib/passwordstate/util.rb', line 21 def camel_case split('_').collect(&:capitalize).join end |
#find_line(&_block) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/passwordstate/util.rb', line 32 def find_line(&_block) raise ArgumentError, 'No block given' unless block_given? each_line do |line| return line if yield line end end |
#snake_case ⇒ Object
25 26 27 28 29 30 |
# File 'lib/passwordstate/util.rb', line 25 def snake_case gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2') .gsub(/([a-z\d])([A-Z])/, '\1_\2') .tr('-', '_') .downcase end |