From 2d0ac967e94c5944ccccf9adad8da5a9d082df29 Mon Sep 17 00:00:00 2001 From: Randy Morgan Date: Sun, 20 Nov 2011 23:44:58 +0900 Subject: pushing docs --- doc/Axlsx/DataTypeValidator.html | 324 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 324 insertions(+) create mode 100644 doc/Axlsx/DataTypeValidator.html (limited to 'doc/Axlsx/DataTypeValidator.html') diff --git a/doc/Axlsx/DataTypeValidator.html b/doc/Axlsx/DataTypeValidator.html new file mode 100644 index 00000000..2dc7891f --- /dev/null +++ b/doc/Axlsx/DataTypeValidator.html @@ -0,0 +1,324 @@ + + + + + + Class: Axlsx::DataTypeValidator + + — Documentation by YARD 0.7.3 + + + + + + + + + + + + + + + + + + + + + + +

Class: Axlsx::DataTypeValidator + + + +

+ +
+ +
Inherits:
+
+ Object + +
    +
  • Object
  • + + + +
+ show all + +
+ + + + + + + + + +
Defined in:
+
lib/axlsx/util/validators.rb
+ +
+
+ +

Overview

+
+

+Validate that the class of the value provided is either an instance or the +class of the allowed types and that any specified additional validation +returns true. +

+ + +
+
+
+ + +
+ + + + + +

+ Class Method Summary + (collapse) +

+ + + + + + +
+

Class Method Details

+ + +
+

+ + + (Boolean) validate(name, types, v, other = lambda{|v| true }) + + + +

+
+

+Perform validation +

+ + +
+
+
+

Parameters:

+
    + +
  • + + name + + + (String) + + + + — +

    +The name of what is being validated. This is included in the error message +

    +
    + +
  • + +
  • + + types + + + (Array, Class) + + + + — +

    +A single class or array of classes that the value is validated against. +

    +
    + +
  • + +
  • + + other + + + (Block) + + + (defaults to: lambda{|v| true }) + + + — +

    +Any block that must evaluate to true for the value to be valid +

    +
    + +
  • + +
+ +

Returns:

+
    + +
  • + + + (Boolean) + + + + — +

    +true if validation succeeds. +

    +
    + +
  • + +
+

Raises:

+
    + +
  • + + + (ArugumentError) + + + + — +

    +Raised if the class of the value provided is not in the specified array of +types or the block passed returns false +

    +
    + +
  • + +
+ +

See Also:

+ + +
+ + + + +
+
+
+
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+
+
# File 'lib/axlsx/util/validators.rb', line 34
+
+def self.validate(name, types, v, other= lambda{|v| true })
+  types = [types] unless types.is_a? Array
+  valid_type = false
+  if v.class == Class
+    types.each { |t| valid_type = true if v.ancestors.include?(t) }
+  else
+    types.each { |t| valid_type = true if v.is_a?(t) }
+  end
+  raise ArgumentError, (ERR_TYPE % [v.inspect, name, types.inspect]) unless (other.call(v) && valid_type)
+end
+
+
+
+ +
+ +
+ + + + + \ No newline at end of file -- cgit v1.2.3