Class: Ropenlayer::Openlayer::Control
- Inherits:
-
Object
- Object
- Ropenlayer::Openlayer::Control
- Defined in:
- lib/ropenlayer/openlayer/control.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#js_id ⇒ Object
readonly
Returns the value of attribute js_id.
-
#map ⇒ Object
readonly
Returns the value of attribute map.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, map) ⇒ Control
constructor
A new instance of Control.
- #to_js ⇒ Object
Constructor Details
#initialize(name, map) ⇒ Control
Returns a new instance of Control.
17 18 19 20 21 22 |
# File 'lib/ropenlayer/openlayer/control.rb', line 17 def initialize(name, map) @name = name @map = map @js_id = "#{ map.js_id }_#{ name }" @config = Ropenlayer::Openlayer::Control.configs[name] end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/ropenlayer/openlayer/control.rb', line 5 def config @config end |
#js_id ⇒ Object (readonly)
Returns the value of attribute js_id.
7 8 9 |
# File 'lib/ropenlayer/openlayer/control.rb', line 7 def js_id @js_id end |
#map ⇒ Object (readonly)
Returns the value of attribute map.
8 9 10 |
# File 'lib/ropenlayer/openlayer/control.rb', line 8 def map @map end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/ropenlayer/openlayer/control.rb', line 6 def name @name end |
Class Method Details
.build_collection(map) ⇒ Object
10 11 12 13 14 15 |
# File 'lib/ropenlayer/openlayer/control.rb', line 10 def self.build_collection(map) map.control_names.inject([]) do |controls, control_name| controls << new(control_name, map) controls end end |
Instance Method Details
#to_js ⇒ Object
24 25 26 27 28 29 |
# File 'lib/ropenlayer/openlayer/control.rb', line 24 def to_js %(// Adding #{ @name } control #{ Ropenlayer::Openlayer::Js.new_var(@js_id, "#{ Ropenlayer::Openlayer::Js.new_method(@config[:method], @config) }").to_js } #{ Ropenlayer::Openlayer::Js.new("#{ map.js_id }.addControl(#{ @js_id })").to_js } ) end |