Class: WsdlMapper::Naming::TypeName

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl_mapper/naming/type_name.rb

Overview

Class to represent the (ruby) type name for an XML (complex or simple) type. This includes the ruby class name and module hierarchy, as well as file name + file path.

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (TypeName) initialize(class_name, module_path, file_name, file_path)

Initialize a new instance with the given names / paths

Parameters:

  • class_name (String)
  • module_path (Array<String>)
  • file_name (String)
  • file_path (Array<String>)


28
29
30
31
32
33
# File 'lib/wsdl_mapper/naming/type_name.rb', line 28

def initialize(class_name, module_path, file_name, file_path)
  @class_name = class_name
  @module_path = module_path
  @file_name = file_name
  @file_path = file_path
end

Instance Attribute Details

- (String) class_name (readonly) Also known as: module_name

Returns Class name of the ruby class (to generate), without enclosing modules. E.g. "Note" for ::ModuleA::ModuleB::Note.

Returns:

  • (String)

    Class name of the ruby class (to generate), without enclosing modules. E.g. "Note" for ::ModuleA::ModuleB::Note.



18
19
20
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18

def class_name
  @class_name
end

- (String) file_name (readonly)

Returns File name where to put the ruby class into (including the '.rb' extension). E.g. "note.rb"

Returns:

  • (String)

    File name where to put the ruby class into (including the '.rb' extension). E.g. "note.rb"



18
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18

attr_reader :class_name, :module_path, :file_name, :file_path

- (Object) file_path (readonly)

Returns the value of attribute file_path



18
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18

attr_reader :class_name, :module_path, :file_name, :file_path

- (Array<String>) module_path (readonly)

Returns Hierarchy of enclosing ruby modules. E.g. ["ModuleA", "ModuleB"] for ::ModuleA::ModuleB::Note.

Returns:

  • (Array<String>)

    Hierarchy of enclosing ruby modules. E.g. ["ModuleA", "ModuleB"] for ::ModuleA::ModuleB::Note.



18
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18

attr_reader :class_name, :module_path, :file_name, :file_path

- (TypeName) parent

Returns Parent WsdlMapper::Naming::TypeName, usually representing a module, that contains several classes.

Returns:



18
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18

attr_reader :class_name, :module_path, :file_name, :file_path

Instance Method Details

- (true, false) eql?(other) Also known as: ==

Determines if this type name is equal to other. Two type names are considered equal, if their #name is equal.

Parameters:

  • other (TypeName)

    Other type name to compare to

Returns:

  • (true, false)


66
67
68
# File 'lib/wsdl_mapper/naming/type_name.rb', line 66

def eql?(other)
  self.class == other.class && name == other.name
end

- (String) name

Full qualified ruby class name, including enclosing modules and root module prefix, e.g. "::ModuleA::ModuleB::Note"

Returns:

  • (String)


58
59
60
# File 'lib/wsdl_mapper/naming/type_name.rb', line 58

def name
  @name ||= ['', *@module_path, @class_name] * '::'
end

- (Array<TypeName>) parents

Returns the hierarchy of parents.

Returns:

  • (Array<TypeName>)

    List of ancestors, with the immediate #parent as first element. [] if this is at root level.



39
40
41
42
43
44
45
# File 'lib/wsdl_mapper/naming/type_name.rb', line 39

def parents
  @parents ||= if parent.nil?
    []
  else
    [parent] + parent.parents
  end
end

- (String) require_path

Returns the path necessary to require this type later on.

Returns:

  • (String)

    Full (relative) path (excluding the extension) to use in a require statement. E.g. "module_a/module_b/note"



51
52
53
# File 'lib/wsdl_mapper/naming/type_name.rb', line 51

def require_path
  @require_path ||= File.join *@file_path, File.basename(@file_name, '.rb')
end