Sha256: cffcc124a132cb7422733835c1ecb4fee3f926dc685121b753e3fbff95bc8d98

Contents?: true

Size: 1.04 KB

Versions: 16

Compression:

Stored size: 1.04 KB

Contents

module Platformx
  # Text helpers module
  # @author Tim Mushen
	module TextHelpers

# Generates slug from text
# @param slug [String] text to slug
# @return [String] slugged text
def x_slug(slug: "")
  return slug.slugify
end

# Generate boolean label
# @param value [Boolean] boolean value
# @param type [String] boolean label type
# @return [String] boolean label (yes or no for boolean value)
# @example
#   x_boolean_label(true) # -> "Yes"
#   x_boolean_label(false) # -> "No"
def x_boolean_label(value: "", type: "text")

	if !value.nil? && value == true
		str = "Yes"
	else
		str = "No"
	end
	
	return str

end

# Generate icon label
# @param value [Boolean] boolean value
# @param type [String] boolean label type
# @return [String] boolean label (yes or no for boolean value)
# @example
#   x_boolean_label(true) # -> "Yes"
#   x_boolean_label(false) # -> "No"
def x_boolean_icon(value)

	if !value.nil? && value == true
		str = "<i class='fa fa-check text-success'></i>"
	else
		str = "<i class='fa fa-ban text-danger'></i>"
	end
	
	return str

end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
platformx-0.0.9.7.2 lib/platformx/text.rb
platformx-0.0.9.7.1 lib/platformx/text.rb
platformx-0.0.9.6.6.7 lib/platformx/text.rb
platformx-0.0.9.6.6.6 lib/platformx/text.rb
platformx-0.0.9.6.6.5 lib/platformx/text.rb
platformx-0.0.9.6.6.4 lib/platformx/text.rb
platformx-0.0.9.6.6.3 lib/platformx/text.rb
platformx-0.0.9.6.6.2 lib/platformx/text.rb
platformx-0.0.9.6.6.1 lib/platformx/text.rb
platformx-0.0.9.6.4 lib/platformx/text.rb
platformx-0.0.9.6.3 lib/platformx/text.rb
platformx-0.0.9.6.2 lib/platformx/text.rb
platformx-0.0.9.6.1 lib/platformx/text.rb
platformx-0.0.9.6 lib/platformx/text.rb
platformx-0.0.9.5 lib/platformx/text.rb
platformx-0.0.9.4 lib/platformx/text.rb