Class: NoBrainer::Geo::Circle

Inherits:
Struct
  • Object
show all
Includes:
Base
Defined in:
lib/no_brainer/geo/circle.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

normalize_geo_options

Constructor Details

#initialize(*args) ⇒ Circle

Returns a new instance of Circle.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/no_brainer/geo/circle.rb', line 4

def initialize(*args)
  options = args.extract_options!
  options = NoBrainer::Geo::Base.normalize_geo_options(options)

  raise NoBrainer::Error::InvalidType if args.size > 2
  center = args[0] || options.delete(:center)
  radius = args[1] || options.delete(:radius)

  center = NoBrainer::Geo::Point.nobrainer_cast_user_to_model(center)
  radius = Float.nobrainer_cast_user_to_model(radius)

  self.center = center
  self.radius = radius
  self.options = options
end

Instance Attribute Details

#centerObject

Returns the value of attribute center

Returns:

  • (Object)

    the current value of center



1
2
3
# File 'lib/no_brainer/geo/circle.rb', line 1

def center
  @center
end

#optionsObject

Returns the value of attribute options

Returns:

  • (Object)

    the current value of options



1
2
3
# File 'lib/no_brainer/geo/circle.rb', line 1

def options
  @options
end

#radiusObject

Returns the value of attribute radius

Returns:

  • (Object)

    the current value of radius



1
2
3
# File 'lib/no_brainer/geo/circle.rb', line 1

def radius
  @radius
end

Instance Method Details

#to_rqlObject



20
21
22
# File 'lib/no_brainer/geo/circle.rb', line 20

def to_rql
  RethinkDB::RQL.new.circle(center.to_rql, radius, options)
end