Class: Capybara::UI::StringValue

Inherits:
String
  • Object
show all
Defined in:
lib/capybara/ui/widgets/string_value.rb

Defined Under Namespace

Classes: Money

Instance Method Summary collapse

Instance Method Details

#to_date(format = nil) ⇒ Object


4
5
6
# File 'lib/capybara/ui/widgets/string_value.rb', line 4

def to_date(format = nil)
  format ? Date.strptime(self, format) : super()
end

#to_keyObject


8
9
10
11
12
13
14
15
16
17
# File 'lib/capybara/ui/widgets/string_value.rb', line 8

def to_key
  fst, rest = first, self[1..-1]
  decamelized = fst + rest.gsub(/([A-Z])/, '_\1')
  underscored = decamelized.gsub(/[\W_]+/, '_')
  stripped = underscored.gsub(/^_|_$/, '')
  downcased = stripped.downcase
  key = downcased.to_sym

  key
end

#to_splitObject


40
41
42
# File 'lib/capybara/ui/widgets/string_value.rb', line 40

def to_split
  split(',').map(&:strip).map { |e| self.class.new(e) }
end

#to_usdObject


36
37
38
# File 'lib/capybara/ui/widgets/string_value.rb', line 36

def to_usd
  Money.new(self)
end