Class: Xumlidot::Types::Constant
- Inherits:
-
Object
- Object
- Xumlidot::Types::Constant
- Defined in:
- lib/xumlidot/types/constant.rb
Overview
Our representation of a constant - although just a string we need to be able to be unambigous in the representation.
name is a single constant, namespace is the remaining full path
e.g For ::Xumlidot::Types::Constant tne name would be Constant and the namespace [Types, Xumlidot]
Note I am REALLY not happy with this design …
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#namespace ⇒ Object
readonly
Returns the value of attribute namespace.
-
#reference ⇒ Object
Returns the value of attribute reference.
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(name, namespace = nil) ⇒ Constant
constructor
TODO: What IS this? I think I may have thrown this in to fix a traversal issue if so…hack!.
- #to_s ⇒ Object
Constructor Details
#initialize(name, namespace = nil) ⇒ Constant
TODO: What IS this? I think I may have thrown this in to fix a traversal issue if so…hack!
25 26 27 28 |
# File 'lib/xumlidot/types/constant.rb', line 25 def initialize(name, namespace = nil) @name = name @namespace = namespace ? namespace.dup : [] end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
19 20 21 |
# File 'lib/xumlidot/types/constant.rb', line 19 def name @name end |
#namespace ⇒ Object (readonly)
Returns the value of attribute namespace.
19 20 21 |
# File 'lib/xumlidot/types/constant.rb', line 19 def namespace @namespace end |
#reference ⇒ Object
Returns the value of attribute reference.
22 23 24 |
# File 'lib/xumlidot/types/constant.rb', line 22 def reference @reference end |
Instance Method Details
#empty? ⇒ Boolean
34 35 36 |
# File 'lib/xumlidot/types/constant.rb', line 34 def empty? @name.nil? && @namespace.empty? end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/xumlidot/types/constant.rb', line 30 def to_s "#{@name} (#{formatted_namespace})" end |