class Xumlidot::Types::Constant

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 …

Attributes

name[R]
namespace[R]
reference[RW]

Public Class Methods

new(name, namespace = nil) click to toggle source

in to fix a traversal issue if so…hack!

# File lib/xumlidot/types/constant.rb, line 25
def initialize(name, namespace = nil)
  @name = name
  @namespace = namespace ? namespace.dup : []
end

Public Instance Methods

empty?() click to toggle source
# File lib/xumlidot/types/constant.rb, line 34
def empty?
  @name.nil? && @namespace.empty?
end
to_s() click to toggle source
# File lib/xumlidot/types/constant.rb, line 30
def to_s
  "#{@name} (#{formatted_namespace})"
end

Private Instance Methods

formatted_namespace() click to toggle source
# File lib/xumlidot/types/constant.rb, line 44
def formatted_namespace
  [@namespace].flatten.reverse.each(&:to_s).join('::')
end
root() click to toggle source
# File lib/xumlidot/types/constant.rb, line 40
def root
  return '::' if @namespace.empty?
end