Class: Ruvi::Selection
- Inherits:
-
Object
- Object
- Ruvi::Selection
- Defined in:
- lib/selections.rb
Instance Attribute Summary collapse
-
#e ⇒ Object
Returns the value of attribute e.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#s ⇒ Object
Returns the value of attribute s.
Instance Method Summary collapse
-
#initialize(s = Point.new, e = Point.new, mode = nil) ⇒ Selection
constructor
A new instance of Selection.
- #invalid? ⇒ Boolean
- #reverse ⇒ Object
- #right_way_up ⇒ Object
Constructor Details
Instance Attribute Details
#e ⇒ Object
Returns the value of attribute e.
14 15 16 |
# File 'lib/selections.rb', line 14 def e @e end |
#mode ⇒ Object
Returns the value of attribute mode.
15 16 17 |
# File 'lib/selections.rb', line 15 def mode @mode end |
#s ⇒ Object
Returns the value of attribute s.
14 15 16 |
# File 'lib/selections.rb', line 14 def s @s end |
Instance Method Details
#invalid? ⇒ Boolean
20 21 22 |
# File 'lib/selections.rb', line 20 def invalid? self.s.nil? || self.e.nil? end |
#reverse ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/selections.rb', line 23 def reverse mydup = self.dup tmp = mydup.s mydup.s = mydup.e mydup.e = tmp mydup end |
#right_way_up ⇒ Object
30 31 32 33 34 |
# File 'lib/selections.rb', line 30 def right_way_up raise "right_way_up called for selection with nil s" if @s.nil? raise "right_way_up called for selection with nil e" if @e.nil? (@e > @s) ? self : reverse end |