Class: SortedArrayBinary::ComparisonState
- Inherits:
-
Object
- Object
- SortedArrayBinary::ComparisonState
- Defined in:
- lib/sorted_array_binary.rb
Overview
{{{2 ComparisonState
Instance Method Summary collapse
- #equal? ⇒ Boolean
- #greater? ⇒ Boolean
-
#initialize(state) ⇒ ComparisonState
constructor
:nodoc:.
- #less? ⇒ Boolean
Constructor Details
#initialize(state) ⇒ ComparisonState
:nodoc:
19 20 21 22 23 24 |
# File 'lib/sorted_array_binary.rb', line 19 def initialize state raise ArgumentError, "invalid state: #{state.inspect}" \ unless state && state >= -1 && state <= 1 @state = state end |
Instance Method Details
#equal? ⇒ Boolean
26 27 28 |
# File 'lib/sorted_array_binary.rb', line 26 def equal? @state == 0 end |
#greater? ⇒ Boolean
30 31 32 |
# File 'lib/sorted_array_binary.rb', line 30 def greater? @state == 1 end |
#less? ⇒ Boolean
34 35 36 |
# File 'lib/sorted_array_binary.rb', line 34 def less? @state == -1 end |