Sha256: db0d631a8dd9b7728dfb08ee47b4fda0f5763c101952ade61ed4b5e2aad89723

Contents?: true

Size: 535 Bytes

Versions: 3

Compression:

Stored size: 535 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

  def to_i
    self ? 1 : 0
  end
end

class TrueClass
  include BooleanHelper
end

class FalseClass
  include BooleanHelper
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
render-text-helper-0.3.2 lib/render/text/helper/boolean.rb
render-text-helper-0.3.1 lib/render/text/helper/boolean.rb
render-text-helper-0.3.0 lib/render/text/helper/boolean.rb