class Xumlidot::Types::Argument

Value object for an argument as specified within a methods definition.

e.g. def foo(a, b)

a and b are the arguments

Depending on the argument; type (TODO), assign and default may be unpopulated e.g.

def foo(a, b)

will be parsed with an empty assign and default, whereas

def bar(a = 1, b = nil)

will both have an assign of '=' and defaults of 1 and :nil respectively.

This is :nil rather than nill since an assignment to a variable of nil is parsed in Args and the default value set to the symbol :nil

Attributes

assign[RW]
default[RW]
name[R]

:types # TODO: determine the type of the argument

Public Class Methods

new() click to toggle source
# File lib/xumlidot/types/argument.rb, line 33
def initialize
  # @types = []
end

Public Instance Methods

name=(val) click to toggle source
# File lib/xumlidot/types/argument.rb, line 37
def name=(val)
  @name = val.tr('&', '')
end
to_s() click to toggle source
# File lib/xumlidot/types/argument.rb, line 41
def to_s
  str_default = case default
                when :nil
                  'nil'
                when String
                  default
                when NilClass
                  nil
                when Symbol
                  ":#{default}"
                when Hash
                  '{}' # TODO: Some hashes were crashing the parser, why?
                else
                  default.to_s
                end

  [@name, @assign, str_default || nil].compact.join(' ')
end