Class: WWT_layer
- Inherits:
-
Object
- Object
- WWT_layer
- Defined in:
- lib/WWT/WWT_layer.rb
Instance Attribute Summary collapse
-
#layer_id ⇒ Object
Returns the value of attribute layer_id.
-
#telescope ⇒ Object
Returns the value of attribute telescope.
Class Method Summary collapse
Instance Method Summary collapse
- #get_property(property_name) ⇒ Object
-
#initialize(telescope, layer_id) ⇒ WWT_layer
constructor
A new instance of WWT_layer.
- #method_missing(method_name, *args) ⇒ Object
- #set_property(property_name, args) ⇒ Object
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
26 27 28 |
# File 'lib/WWT/WWT_layer.rb', line 26 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 |
# File 'lib/WWT/WWT_layer.rb', line 14 def get_property(property_name) 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
21 22 23 24 |
# File 'lib/WWT/WWT_layer.rb', line 21 def set_property(property_name,args) name = WWT_layer.sanitize_property_name(property_name.to_s) @telescope.setprop :id => layer_id, :propname => name, :propvalue=>args end |