Class: RXSD::ObjectBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/rxsd/builder.rb

Overview

Base interface and helper methods to build objects in various formats from specified parameters

Direct Known Subclasses

RubyObjectBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ ObjectBuilder

Create a new class builder w/ specified args



131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/rxsd/builder.rb', line 131

def initialize(args = {})
   if args.has_key? :builder
     @tag_name           = args[:builder].tag_name
     @content            = args[:builder].content
     @obj                = args[:builder].obj
     @attributes         = args[:builder].attributes
     @children           = args[:builder].children
     @parent             = args[:builder].parent

   else
     @tag_name   = args[:tag_name]
     @content    = args[:content]
     @obj        = args[:obj]
     @attributes = args[:attributes]
     @children   = args[:children]
     @parent     = args[:parent]

   end

   @children = [] if @children.nil?
   @attributes = [] if @attributes.nil?
end

Instance Attribute Details

#attributesObject

hash of attribute names / values to assign to class instance attributes



122
123
124
# File 'lib/rxsd/builder.rb', line 122

def attributes
  @attributes
end

#childrenObject

array of children object builders to construct instances and assign to class instance attributes



125
126
127
# File 'lib/rxsd/builder.rb', line 125

def children
  @children
end

#contentObject

content, for text based data types, will contain text to instantiate object w/ TODO might want at some point to store a bool in ClassBuilder (only set to true in SimpleType) indicating that constructed class is a text based type, for verification purposes



116
117
118
# File 'lib/rxsd/builder.rb', line 116

def content
  @content
end

#objObject

actual object built



119
120
121
# File 'lib/rxsd/builder.rb', line 119

def obj
  @obj
end

#parentObject

parent object builder, optionally set



128
129
130
# File 'lib/rxsd/builder.rb', line 128

def parent
  @parent
end

#tag_nameObject

name of class instance to build



111
112
113
# File 'lib/rxsd/builder.rb', line 111

def tag_name
  @tag_name
end