Class: ThreeScaleToolbox::Helper::BooleanTransformer

Inherits:
Object
  • Object
show all
Defined in:
lib/3scale_toolbox/helper.rb

Instance Method Summary collapse

Instance Method Details

#call(param_str) ⇒ Object

Raises:

  • (ArgumentError)


76
77
78
79
80
81
82
83
# File 'lib/3scale_toolbox/helper.rb', line 76

def call(param_str)
  raise ArgumentError unless param_str.is_a?(String)

  return true if true?(param_str)
  return false if false?(param_str)

  raise ArgumentError
end

#false?(param_str) ⇒ Boolean

Returns:

  • (Boolean)


94
95
96
97
98
99
100
101
# File 'lib/3scale_toolbox/helper.rb', line 94

def false?(param_str)
  case param_str
  when 'false', '0'
    true
  else
    false
  end
end

#true?(param_str) ⇒ Boolean

Returns:

  • (Boolean)


85
86
87
88
89
90
91
92
# File 'lib/3scale_toolbox/helper.rb', line 85

def true?(param_str)
  case param_str
  when 'true', '1'
    true
  else
    false
  end
end