Class: WindowTerminal::Orientation
- Inherits:
-
Object
- Object
- WindowTerminal::Orientation
- Defined in:
- lib/accu-window.rb
Overview
A class which stores the Orientation of an object.
Instance Attribute Summary collapse
-
#x ⇒ Object
readonly
Returns the value of attribute x.
-
#y ⇒ Object
readonly
Returns the value of attribute y.
Instance Method Summary collapse
-
#[](index) ⇒ Object
Allows for array-like indexing.
-
#initialize(x = 0, y = 0) ⇒ Orientation
constructor
Initializes an Orienation object.
-
#to_s ⇒ Object
Makes the to_s return a more “bootiful” string.
Constructor Details
#initialize(x = 0, y = 0) ⇒ Orientation
Initializes an Orienation object.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/accu-window.rb', line 51 def initialize(x=0,y=0) if x != -1 and x != 0 and x != 1 then x = 0 end if y != -1 and y != 0 and y != 1 then y = 0 end @x = x @y = y end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
48 49 50 |
# File 'lib/accu-window.rb', line 48 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
48 49 50 |
# File 'lib/accu-window.rb', line 48 def y @y end |
Instance Method Details
#[](index) ⇒ Object
Allows for array-like indexing. 0 - @x, 1 - @y
70 71 72 73 74 75 76 77 |
# File 'lib/accu-window.rb', line 70 def [](index) assert RangeError "Index must be either 0 or 1!" if not (index == 0 or index == 1) if index == 0 then return @x.dup else return @y.dup end end |
#to_s ⇒ Object
Makes the to_s return a more “bootiful” string.
64 65 66 |
# File 'lib/accu-window.rb', line 64 def to_s "#{@x}|#{@y}" end |