Class: Sane::API::OptionDescriptor::Range

Inherits:
Struct
  • Object
show all
Includes:
Comparable, Enumerable
Defined in:
lib/sane/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#maxObject

Returns the value of attribute max

Returns:

  • (Object)

    the current value of max



30
31
32
# File 'lib/sane/api.rb', line 30

def max
  @max
end

#minObject

Returns the value of attribute min

Returns:

  • (Object)

    the current value of min



30
31
32
# File 'lib/sane/api.rb', line 30

def min
  @min
end

#quantObject

Returns the value of attribute quant

Returns:

  • (Object)

    the current value of quant



30
31
32
# File 'lib/sane/api.rb', line 30

def quant
  @quant
end

Instance Method Details

#<=>(x) ⇒ Object



33
34
35
# File 'lib/sane/api.rb', line 33

def <=> x
  (min..max) <=> x
end

#===(x) ⇒ Object



41
42
43
# File 'lib/sane/api.rb', line 41

def === x
  x.kind_of?( Numeric) and include?( x)
end

#eachObject



45
46
47
# File 'lib/sane/api.rb', line 45

def each
  min.step( max, [1,quant].max)
end

#include?(x) ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/sane/api.rb', line 37

def include? x
  (min..max).include?( x) and 0 == (x-min) % quant
end