Class: CanControlsGateway::CursorVector
- Inherits:
-
Object
- Object
- CanControlsGateway::CursorVector
- Defined in:
- lib/cursor_vector.rb
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
- #dimensions ⇒ Object
-
#initialize(xml_node) ⇒ CursorVector
constructor
A new instance of CursorVector.
- #is_valid? ⇒ Boolean
- #to_s ⇒ Object
Constructor Details
#initialize(xml_node) ⇒ CursorVector
Returns a new instance of CursorVector.
10 11 12 13 14 15 16 |
# File 'lib/cursor_vector.rb', line 10 def initialize xml_node @xml_node = REXML::Document.new(xml_node.to_s) @x = nil @y = nil parse_xml end |
Instance Attribute Details
#x ⇒ Object (readonly)
Returns the value of attribute x.
8 9 10 |
# File 'lib/cursor_vector.rb', line 8 def x @x end |
#y ⇒ Object (readonly)
Returns the value of attribute y.
8 9 10 |
# File 'lib/cursor_vector.rb', line 8 def y @y end |
Instance Method Details
#dimensions ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/cursor_vector.rb', line 26 def dimensions if is_valid? 2 else 0 end end |
#is_valid? ⇒ Boolean
18 19 20 21 22 23 24 |
# File 'lib/cursor_vector.rb', line 18 def is_valid? if (@y && @x) true else false end end |
#to_s ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/cursor_vector.rb', line 34 def to_s if is_valid? "#{x},#{y}" else "" end end |