Module: SKUI::TypeCheck
- Defined in:
- src/SKUI/typecheck.rb
Overview
Module collection of ‘Proc`s that can be used to check types when defining properties. The Proc should return the value given. Return unmodified to preserve the value as it was given, or made modifications, such as for a boolean type check you want to convert the value, that might be any value, to a true boolean.
Constant Summary collapse
- BOOLEAN =
Proc.new { |value| # Cast the value into true boolean values. value ? true : false }
- BUTTON =
Proc.new { |value| unless value.is_a?( Button ) raise( ArgumentError, 'Not a valid button.' ) end value }
- COLOR =
Proc.new { |value| unless value.is_a?( Sketchup::Color ) || SystemColor.valid?( value ) raise( ArgumentError, 'Not a valid color.' ) end value }
- CONTAINER =
Proc.new { |value| unless value.is_a?( ControlManager ) raise( ArgumentError, 'Not a valid container control.' ) end value }
- CONTROL =
Proc.new { |value| unless value.is_a?( Control ) raise( ArgumentError, 'Not a valid control.' ) end value }
- FONT =
Proc.new { |value| unless value.is_a?( Font ) || SystemFont.valid?( value ) raise( ArgumentError, 'Not a valid font.' ) end value }
- INTEGER =
Proc.new { |value| unless value.respond_to?( :to_i ) raise( ArgumentError, 'Not a valid Integer value.' ) end value.to_i }
- TEXTALIGN =
Proc.new { |value| unless [:left, :center, :right].include?( value ) raise( ArgumentError, 'Not a valid alignment value.' ) end value }
- STRING =
Proc.new { |value| unless value.respond_to?( :to_s ) raise( ArgumentError, 'Not a valid String value.' ) end value.to_s }
- SYMBOL =
Proc.new { |value| unless value.is_a?( Symbol ) raise( ArgumentError, 'Not a Symbol.' ) end value }