Class: Vizier::Node
- Includes:
- Support
- Defined in:
- lib/support/vizier.rb
Constant Summary
Constants included from Support
Instance Attribute Summary collapse
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#name ⇒ Object
Returns the value of attribute name.
-
#object ⇒ Object
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name = nil, attrs = {}) ⇒ Node
constructor
A new instance of Node.
- #to_s ⇒ Object
- #to_str ⇒ Object
Methods included from Support
#attributes, #attributes=, included, #legal?, #quote, #sanitize
Methods inherited from Base
Constructor Details
#initialize(name = nil, attrs = {}) ⇒ Node
Returns a new instance of Node.
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/support/vizier.rb', line 132 def initialize( name = nil, attrs={} ) self.attributes = attrs if name.is_a?( String ) self.name = name @label = attrs.delete(:label) || name else @object = name self.name = Node.make_name( @object ) @label = attrs.delete(:label) || Node.first_response( @object, :name, :identifier, :label ) || name end end |
Instance Attribute Details
#fields ⇒ Object
Returns the value of attribute fields.
129 130 131 |
# File 'lib/support/vizier.rb', line 129 def fields @fields end |
#name ⇒ Object
Returns the value of attribute name.
130 131 132 |
# File 'lib/support/vizier.rb', line 130 def name @name end |
#object ⇒ Object
Returns the value of attribute object.
128 129 130 |
# File 'lib/support/vizier.rb', line 128 def object @object end |
Class Method Details
.first_response(obj, *method_names) ⇒ Object
148 149 150 151 |
# File 'lib/support/vizier.rb', line 148 def self.first_response obj, *method_names responder = method_names.flatten.detect { |m| obj.respond_to?(m) } obj.send( responder ) unless responder.nil? end |
.make_name(obj) ⇒ Object
144 145 146 |
# File 'lib/support/vizier.rb', line 144 def self.make_name( obj ) sanitize [ obj.class, first_response( obj, :name, :identifier, :id, :hash)].join('_') end |