Module: Vedeu::Geometry::Validator Private

Includes:
Common
Included in:
DSL
Defined in:
lib/vedeu/geometry/validator.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Validate values given to DSL.

Instance Method Summary collapse

Instance Method Details

#absent?(variable) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether a variable is nil or empty.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

#demodulize(klass) ⇒ String Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Removes the module part from the expression in the string.

Examples:

demodulize('Vedeu::SomeModule::SomeClass') # => "SomeClass"

Parameters:

  • klass (Class|String)

Returns:

  • (String)

#present?(variable) ⇒ Boolean Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether a variable has a useful value.

Parameters:

  • variable (String|Symbol|Array|Fixnum)

    The variable to check.

Returns:

  • (Boolean)

#snake_case(name) ⇒ String Originally defined in module Common

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Converts a class name to a lowercase snake case string.

Examples:

snake_case(MyClassName) # => "my_class_name"
snake_case(NameSpaced::ClassName)
# => "name_spaced/class_name"

Parameters:

  • name (String)

Returns:

  • (String)

#validate_height!(value) ⇒ TrueClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Fixnum)

    The number of lines/rows.

Returns:

  • (TrueClass)

Raises:



16
17
18
19
20
21
# File 'lib/vedeu/geometry/validator.rb', line 16

def validate_height!(value)
  fail Vedeu::Error::InvalidSyntax,
       'No height given.'.freeze if absent?(value)

  true
end

#validate_horizontal_alignment!(value) ⇒ TrueClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Symbol)

    One of :center, :centre, :left, :none, :right.

Returns:

  • (TrueClass)

Raises:



27
28
29
30
31
32
33
# File 'lib/vedeu/geometry/validator.rb', line 27

def validate_horizontal_alignment!(value)
  fail Vedeu::Error::InvalidSyntax,
       'No horizontal alignment given. Valid values are :center, ' \
       ':centre, :left, :none, :right.'.freeze unless present?(value)

  true
end

#validate_vertical_alignment!(value) ⇒ TrueClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Symbol)

    One of :bottom, :middle, :none, :top.

Returns:

  • (TrueClass)

Raises:



38
39
40
41
42
43
44
# File 'lib/vedeu/geometry/validator.rb', line 38

def validate_vertical_alignment!(value)
  fail Vedeu::Error::InvalidSyntax,
       'No vertical alignment given. Valid values are :bottom, ' \
       ':middle, :none, :top.'.freeze unless present?(value)

  true
end

#validate_width!(value) ⇒ TrueClass

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Fixnum)

    The number of characters/columns.

Returns:

  • (TrueClass)

Raises:



49
50
51
52
53
54
# File 'lib/vedeu/geometry/validator.rb', line 49

def validate_width!(value)
  fail Vedeu::Error::InvalidSyntax,
       'No width given.'.freeze if absent?(value)

  true
end