Class: CanControlsGateway::CursorVector

Inherits:
Object
  • Object
show all
Defined in:
lib/cursor_vector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xObject (readonly)

Returns the value of attribute x.



8
9
10
# File 'lib/cursor_vector.rb', line 8

def x
  @x
end

#yObject (readonly)

Returns the value of attribute y.



8
9
10
# File 'lib/cursor_vector.rb', line 8

def y
  @y
end

Instance Method Details

#dimensionsObject



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

Returns:

  • (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_sObject



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