Class: Xumlidot::Types::Constant

Inherits:
Object
  • Object
show all
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

Superklass

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



19
20
21
# File 'lib/xumlidot/types/constant.rb', line 19

def name
  @name
end

#namespaceObject (readonly)

Returns the value of attribute namespace.



19
20
21
# File 'lib/xumlidot/types/constant.rb', line 19

def namespace
  @namespace
end

#referenceObject

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

Returns:

  • (Boolean)


34
35
36
# File 'lib/xumlidot/types/constant.rb', line 34

def empty?
  @name.nil? && @namespace.empty?
end

#to_sObject



30
31
32
# File 'lib/xumlidot/types/constant.rb', line 30

def to_s
  "#{@name} (#{formatted_namespace})"
end