Top Level Namespace

Defined Under Namespace

Modules: Yesno

Instance Method Summary collapse

Instance Method Details

#fyesno(to_validate, type = "default", options = "sm") ⇒ Object



23
24
25
# File 'lib/yesno/helpers.rb', line 23

def fyesno(to_validate, type = "default", options = "sm")
  return to_validate ? I18n.t("yesno.#{type}.#{options}t") : I18n.t("yesno.#{type}.#{options}f")
end

#yesno(to_validate, options = {}) ⇒ Object



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/yesno/helpers.rb', line 1

def yesno(to_validate, options = {})
  defaults = {
    :type => "default",
    :pluralize => false,
    :female => false
  }
  options = defaults.merge(options)
  if options[:pluralize] == false
    if options[:female] == false
      return to_validate ? I18n.t("yesno.#{options[:type]}.smt") : I18n.t("yesno.#{options[:type]}.smf")
    else
      return to_validate ? I18n.t("yesno.#{options[:type]}.sft") : I18n.t("yesno.#{options[:type]}.sff")
    end
  else
    if options[:female] == false
      return to_validate ? I18n.t("yesno.#{options[:type]}.pmt") : I18n.t("yesno.#{options[:type]}.pmf")
    else
      return to_validate ? I18n.t("yesno.#{options[:type]}.pft") : I18n.t("yesno.#{options[:type]}.pff")
    end
  end
end