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)


73
74
75
76
77
78
79
80
# File 'lib/3scale_toolbox/helper.rb', line 73

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)


91
92
93
94
95
96
97
98
# File 'lib/3scale_toolbox/helper.rb', line 91

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

#true?(param_str) ⇒ Boolean

Returns:

  • (Boolean)


82
83
84
85
86
87
88
89
# File 'lib/3scale_toolbox/helper.rb', line 82

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