Sha256: 7e1a6dd1be405f38c810f2c881e23dd58afc0ca964bc9f00a7fa28012a7bd9bd

Contents?: true

Size: 500 Bytes

Versions: 1

Compression:

Stored size: 500 Bytes

Contents

# frozen_string_literal: true

# Added methods to boolean module
module BooleanHelper
  def to_yn(capital_letter: true)
    if self
      capital_letter ? 'Y' : 'y'
    else
      capital_letter ? 'N' : 'n'
    end
  end

  # casting: capitalize | upcase | downcase
  def to_yes_no(casting = :capitalize)
    if self
      'yes'.send(casting.to_sym)
    else
      'no'.send(casting.to_sym)
    end
  end
end

class TrueClass
  include BooleanHelper
end

class FalseClass
  include BooleanHelper
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
render-text-helper-0.2.0 lib/render/text/helper/boolean.rb