Class: Cl::Cast::Cast
- Inherits:
-
Struct
- Object
- Struct
- Cl::Cast::Cast
- Defined in:
- lib/cl/cast.rb
Constant Summary collapse
- TRUE =
/^(true|yes|on)$/
- FALSE =
/^(false|no|off)$/
Instance Attribute Summary collapse
-
#opts ⇒ Object
Returns the value of attribute opts.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
Instance Attribute Details
#opts ⇒ Object
Returns the value of attribute opts
3 4 5 |
# File 'lib/cl/cast.rb', line 3 def opts @opts end |
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/cl/cast.rb', line 3 def type @type end |
#value ⇒ Object
Returns the value of attribute value
3 4 5 |
# File 'lib/cl/cast.rb', line 3 def value @value end |
Instance Method Details
#apply ⇒ Object
7 8 9 10 11 12 |
# File 'lib/cl/cast.rb', line 7 def apply return send(type) if respond_to?(type, true) raise ArgumentError, "Unknown type: #{type}" rescue ::ArgumentError => e raise ArgumentError.new(:wrong_type, value.inspect, type) end |