class String

Useful String methods for Jeweler: .true?, .to_b and .money

Public Instance Methods

money() click to toggle source

Parses a number by converting it to a Double, formatting it as money, and then converting it back to String Example: $32.50 (String)

# File lib/bluehelmet/core_ext/String.rb, line 25
def money
  to_d.money.to_s
end
to_b() click to toggle source

Returns true if String is explicitly equal to 'true' Returns false if String is explicitly equal to 'false' raise ArgumentError if any other String is evaluated

# File lib/bluehelmet/core_ext/String.rb, line 11
def to_b
  if to_s == 'true'
    true
  elsif to_s == 'false'
    false
  else
    # raise SyntaxError
    raise ArgumentError 'String being evaluated by to_b can only be equal to True or False'
  end
end
true?() click to toggle source

Returns true if the string is equal to 'true'

# File lib/bluehelmet/core_ext/String.rb, line 4
def true?
  to_s == 'true'
end
uglify() click to toggle source

Undoes a titleize by addinig underscores and making lowercase returns String. ActionSupport alternative is `.parameterize` Example Nice Title -> nice_title (String)

# File lib/bluehelmet/core_ext/String.rb, line 32
def uglify
  self.gsub(' ', '_').downcase
end