Class: Kamelopard::XY

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

Overview

Internal class used where KML requires X and Y values and units

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x = 0.5, y = 0.5, xunits = :fraction, yunits = :fraction) ⇒ XY

Returns a new instance of XY.



877
878
879
880
881
882
# File 'lib/kamelopard/classes.rb', line 877

def initialize(x = 0.5, y = 0.5, xunits = :fraction, yunits = :fraction)
    @x = x
    @y = y
    @xunits = xunits
    @yunits = yunits
end

Instance Attribute Details

#xObject

Returns the value of attribute x.



876
877
878
# File 'lib/kamelopard/classes.rb', line 876

def x
  @x
end

#xunitsObject

Returns the value of attribute xunits.



876
877
878
# File 'lib/kamelopard/classes.rb', line 876

def xunits
  @xunits
end

#yObject

Returns the value of attribute y.



876
877
878
# File 'lib/kamelopard/classes.rb', line 876

def y
  @y
end

#yunitsObject

Returns the value of attribute yunits.



876
877
878
# File 'lib/kamelopard/classes.rb', line 876

def yunits
  @yunits
end

Instance Method Details

#to_kml(name, elem = nil) ⇒ Object



884
885
886
887
888
889
890
891
892
# File 'lib/kamelopard/classes.rb', line 884

def to_kml(name, elem = nil)
    k = REXML::Element.new name
    k.attributes['x'] = @x
    k.attributes['y'] = @y
    k.attributes['xunits'] = @xunits
    k.attributes['yunits'] = @yunits
    elem.elements << k unless elem.nil?
    k
end