class ListCountComparison

Public Class Methods

new(type, amount) click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 80
def initialize(type, amount)
    @type = type.nil? ? CMP_EQUALS : to_compare(type)
    @amount = amount.nil? ? 1 : to_num(amount)
end

Public Instance Methods

amount() click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 100
def amount
    return amount
end
compare(actual) click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 85
def compare(actual)
    case @type
        when CMP_LESS_THAN then actual < @amount
        when CMP_MORE_THAN then actual > @amount
        when CMP_AT_MOST then actual <= @amount
        when CMP_AT_LEAST then actual >= @amount
        when CMP_EQUALS then actual == @amount
        else actual == @amount
    end
end
compare_to_string() click to toggle source

turn a comparison into a string

# File lib/cucumber-rest-bdd/list.rb, line 105
def compare_to_string()
    case @type
    when CMP_LESS_THAN then 'fewer than '
    when CMP_MORE_THAN then 'more than '
    when CMP_AT_LEAST then 'at least '
    when CMP_AT_MOST then 'at most '
    when CMP_EQUALS then 'exactly '
    else ''
    end
end
to_string() click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 116
def to_string()
    return compare_to_string() + ' ' + @amount.to_s
end
type() click to toggle source
# File lib/cucumber-rest-bdd/list.rb, line 96
def type
    return @type
end