Class: WsdlMapper::Naming::TypeName
- Inherits:
-
Object
- Object
- WsdlMapper::Naming::TypeName
- 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
-
#class_name ⇒ String
(also: #module_name)
readonly
Class name of the ruby class (to generate), without enclosing modules.
-
#file_name ⇒ String
readonly
File name where to put the ruby class into (including the '.rb' extension).
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#module_path ⇒ Array<String>
readonly
Hierarchy of enclosing ruby modules.
-
#parent ⇒ TypeName
Parent TypeName, usually representing a module, that contains several classes.
Instance Method Summary collapse
-
#eql?(other) ⇒ true, false
(also: #==)
Determines if this type name is equal to
other. -
#initialize(class_name, module_path, file_name, file_path) ⇒ TypeName
constructor
Initialize a new instance with the given names / paths.
-
#name ⇒ String
Full qualified ruby class name, including enclosing modules and root module prefix, e.g.
-
#parents ⇒ Array<TypeName>
Returns the hierarchy of parents.
-
#require_path ⇒ String
Returns the path necessary to require this type later on.
Constructor Details
#initialize(class_name, module_path, file_name, file_path) ⇒ TypeName
Initialize a new instance with the given names / paths
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
#class_name ⇒ String (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.
18 19 20 |
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18 def class_name @class_name end |
#file_name ⇒ String (readonly)
Returns 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 |
#file_path ⇒ Object (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 |
#module_path ⇒ Array<String> (readonly)
Returns 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 |
#parent ⇒ TypeName
Returns Parent WsdlMapper::Naming::TypeName, usually representing a module, that contains several classes.
18 |
# File 'lib/wsdl_mapper/naming/type_name.rb', line 18 attr_reader :class_name, :module_path, :file_name, :file_path |
Instance Method Details
#eql?(other) ⇒ true, false Also known as: ==
Determines if this type name is equal to other. Two type names are considered
equal, if their #name is equal.
66 67 68 |
# File 'lib/wsdl_mapper/naming/type_name.rb', line 66 def eql?(other) self.class == other.class && name == other.name end |
#name ⇒ String
Full qualified ruby class name, including enclosing modules and root module prefix, e.g.
"::ModuleA::ModuleB::Note"
58 59 60 |
# File 'lib/wsdl_mapper/naming/type_name.rb', line 58 def name @name ||= ['', *@module_path, @class_name] * '::' end |
#parents ⇒ Array<TypeName>
Returns the hierarchy of parents.
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 |
#require_path ⇒ String
Returns the path necessary to require this type later on.
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 |