Class: WWT_layer
- Inherits:
-
Object
show all
- Defined in:
- lib/WWT/WWT_layer.rb
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(telescope, layer_id) ⇒ WWT_layer
Returns a new instance of WWT_layer.
4
5
6
7
|
# File 'lib/WWT/WWT_layer.rb', line 4
def initialize(telescope,layer_id)
@telescope= telescope
@layer_id = layer_id
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args) ⇒ Object
9
10
11
12
|
# File 'lib/WWT/WWT_layer.rb', line 9
def method_missing (method_name, *args)
set_property(method_name.to_s.gsub("=",""),args.first) if method_name.match(/.*=/)
get_property(method_name) if args.count==0
end
|
Instance Attribute Details
#layer_id ⇒ Object
Returns the value of attribute layer_id.
2
3
4
|
# File 'lib/WWT/WWT_layer.rb', line 2
def layer_id
@layer_id
end
|
#telescope ⇒ Object
Returns the value of attribute telescope.
2
3
4
|
# File 'lib/WWT/WWT_layer.rb', line 2
def telescope
@telescope
end
|
Class Method Details
.sanitize_property_name(name) ⇒ Object
32
33
34
|
# File 'lib/WWT/WWT_layer.rb', line 32
def self.sanitize_property_name(name)
name.split("_").map{|w| w.capitalize}.join("")
end
|
Instance Method Details
#get_property(property_name) ⇒ Object
14
15
16
17
18
19
20
|
# File 'lib/WWT/WWT_layer.rb', line 14
def get_property(property_name)
puts "running get property"
name = WWT_layer.sanitize_property_name(property_name.to_s)
puts "#{name}"
result = @telescope.getprop :id=>layer_id, :propname => name
result[1]["layer"][:properties][name.downcase]
end
|
#set_property(property_name, args) ⇒ Object
22
23
24
25
26
|
# File 'lib/WWT/WWT_layer.rb', line 22
def set_property(property_name,args)
puts "running set property"
name = WWT_layer.sanitize_property_name(property_name.to_s)
@telescope.setprop :id => layer_id, :propname => name, :propvalue=>args
end
|
#update(args) ⇒ Object
28
29
30
|
# File 'lib/WWT/WWT_layer.rb', line 28
def update(args)
@telescope.update args.merge(:id=>layer_id)
end
|