class Foraneus::Converters::Boolean

Boolean converter.

When parsing, the string ‘true’ is converted to true, otherwise false is returned.

When converting to a raw value, a true value => ‘true’, a false value => ‘false’.

Attributes

opts[R]

Public Class Methods

new(opts = {}) click to toggle source
# File lib/foraneus/converters/boolean.rb, line 13
def initialize(opts = {})
  @opts = opts
end

Public Instance Methods

parse(s) click to toggle source

@return [Boolean]

# File lib/foraneus/converters/boolean.rb, line 18
def parse(s)
  if s == 'true'
    true
  else
    false
  end
end
raw(v) click to toggle source
# File lib/foraneus/converters/boolean.rb, line 26
def raw(v)
  if v
    'true'
  else
    'false'
  end
end