Class: ActiveRecordMysqlSpatial::ActiveRecord::MySQL::Polygon

Inherits:
Base
  • Object
show all
Defined in:
lib/active_record_mysql_spatial/active_record/mysql/polygon.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#error, #error_backtrace, #raw

Instance Method Summary collapse

Methods inherited from Base

#deserialize, #serialize

Instance Attribute Details

#itemsObject

Returns the value of attribute items.



10
11
12
# File 'lib/active_record_mysql_spatial/active_record/mysql/polygon.rb', line 10

def items
  @items
end

Instance Method Details

#==(other) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/active_record_mysql_spatial/active_record/mysql/polygon.rb', line 26

def ==(other)
  return false if super == false

  items.each_with_index do |item, index|
    return false if item != other.items[index]
  end

  true
end

#to_coordinates_sqlObject



22
23
24
# File 'lib/active_record_mysql_spatial/active_record/mysql/polygon.rb', line 22

def to_coordinates_sql
  items.map { |linestring| "(#{linestring.to_coordinates_sql})" }.join(', ')
end

#to_sqlObject



16
17
18
19
20
# File 'lib/active_record_mysql_spatial/active_record/mysql/polygon.rb', line 16

def to_sql
  return nil if @items.blank?

  "Polygon(#{to_coordinates_sql})"
end

#typeObject



12
13
14
# File 'lib/active_record_mysql_spatial/active_record/mysql/polygon.rb', line 12

def type
  :polygon
end