Class: WindowTerminal::Orientation

Inherits:
Object
  • Object
show all
Defined in:
lib/accu-window.rb

Overview

A class which stores the Orientation of an object.

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xObject (readonly)

Returns the value of attribute x.



48
49
50
# File 'lib/accu-window.rb', line 48

def x
  @x
end

#yObject (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_sObject

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