Class: QueenCheck::Condition

Inherits:
Object
  • Object
show all
Defined in:
lib/queencheck/condition.rb

Overview

QueenCheck condition class

Examples:

QueenCheck::Alphabet::LowerCase.arbitrary.gen.where(:include? => ['a', 'b', 'c'])

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|value| ... } ⇒ Condition

Returns a new instance of Condition.

Yields:

  • (value)

    generated value

Yield Returns:



8
9
10
# File 'lib/queencheck/condition.rb', line 8

def initialize(&condition)
  @condition = condition
end

Class Method Details

.empty?QueenCheck::Condition

check empty



86
87
88
89
90
# File 'lib/queencheck/condition.rb', line 86

def self.empty?()
  new { |n|
    n.empty?
  }
end

.equal?(m) ⇒ QueenCheck::Condition

check equal m

Parameters:

  • m (Object)

Returns:



96
97
98
99
100
# File 'lib/queencheck/condition.rb', line 96

def self.equal?(m)
  new { |n|
    n == m
  }
end

.include?(ary) ⇒ QueenCheck::Condition

check value in ary

Parameters:

  • ary (Array)

Returns:



48
49
50
51
52
# File 'lib/queencheck/condition.rb', line 48

def self.include?(ary)
  new { |n|
    ary.include?(n)
  }
end

.instance_of?(klass) ⇒ QueenCheck::Condition

check instance of klass

Parameters:

Returns:



58
59
60
61
62
# File 'lib/queencheck/condition.rb', line 58

def self.instance_of?(klass)
  new { |n|
    n.instance_of?(klass)
  }
end

.nil?QueenCheck::Condition

check nil



77
78
79
80
81
# File 'lib/queencheck/condition.rb', line 77

def self.nil?()
  new { |n|
    n.nil?
  }
end

.not_empty?QueenCheck::Condition

not empty?

Returns:

See Also:



91
# File 'lib/queencheck/condition.rb', line 91

def_not :empty?

.not_equal?QueenCheck::Condition

not equal?

Parameters:

  • m (Object)

Returns:

See Also:



101
# File 'lib/queencheck/condition.rb', line 101

def_not :equal?

.not_include?QueenCheck::Condition

not include?

Parameters:

  • ary (Array)

Returns:

See Also:



53
# File 'lib/queencheck/condition.rb', line 53

def_not :include?

.not_instance_of?QueenCheck::Condition

not instance_of?

Parameters:

Returns:

See Also:



63
# File 'lib/queencheck/condition.rb', line 63

def_not :instance_of?

.not_nil?QueenCheck::Condition

not nil?

Returns:

See Also:



82
# File 'lib/queencheck/condition.rb', line 82

def_not :nil?

.not_orderd?QueenCheck::Condition

not orderd?

Returns:

See Also:



110
# File 'lib/queencheck/condition.rb', line 110

def_not :orderd?

.not_respond_to?QueenCheck::Condition

not respond_to?

Parameters:

  • method (Symbol, String)

    method name

Returns:

See Also:



73
# File 'lib/queencheck/condition.rb', line 73

def_not :respond_to?

.orderd?QueenCheck::Condition

check orderd array



105
106
107
108
109
# File 'lib/queencheck/condition.rb', line 105

def self.orderd?
  new { |n|
    n.sort == n
  }
end

.respond_to?(method) ⇒ QueenCheck::Condition

check respond to method

Parameters:

  • method (Symbol, String)

    method name

Returns:



68
69
70
71
72
# File 'lib/queencheck/condition.rb', line 68

def self.respond_to?(method)
  new { |n|
    n.respond_to?(method)
  }
end

Instance Method Details

#match?(n) ⇒ Boolean

Returns condition matched.

Parameters:

  • n (Object)

    any value

Returns:



14
15
16
# File 'lib/queencheck/condition.rb', line 14

def match?(n)
  @condition.call(n)
end