Class: Document
Instance Attribute Summary
Attributes inherited from Node
#children, #level, #name, #parent
Instance Method Summary collapse
-
#initialize ⇒ Document
constructor
A new instance of Document.
- #parse_args ⇒ Object
Methods inherited from Node
#add_child, #all_children, #print, #print_children, #root, #root?, #to_s
Constructor Details
#initialize ⇒ Document
Returns a new instance of Document.
250 251 252 253 |
# File 'lib/rest.rb', line 250 def initialize super self.name = "DOCUMENT" end |
Instance Method Details
#parse_args ⇒ Object
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/rest.rb', line 255 def parse_args sections = Hash.new sections[ 0 ] = self @section = nil while line = gets if ( line =~ /^\s+(\S.*)$/ ) if ( !@text ) @text = Text.new end @text.append $1 else if ( @text && @current ) @current.add_child @text end @text = nil end if ( line =~ /^(=+) (.*)/ ) level = $1.size title = $2 @section = Section.new title @current = @section parent = sections[ level - 1 ] parent.add_child @section sections[ level ] = @section elsif ( line =~ /^(GET|PUT|POST|DELETE) (.*)/ ) @request = Request.new @current = @request @request.verb = $1 @request.path = $2 @section.add_child( @request ) elsif ( line =~ /^<(.*)>: (.*)/ ) parameter = Parameter.new parameter.name = $1 parameter.description = $2 @current.add_child( parameter ) elsif ( line =~ /^Host: (.*)/ ) host = Host.new $1 @current.add_child( host ) elsif ( line =~ /^Body: (.*)/ ) body = Body.new $1 @current.add_child( body ) elsif ( line =~ /^Result: (.*)/ ) result = Result.new $1 @current.add_child( result ) elsif ( line =~ /^XmlBody: (.*)/ ) body = XmlBody.new $1 @current.add_child( body ) elsif ( line =~ /^XmlResult: (.*) +(.*)/ ) result = XmlResult.new $1 result.schema = $2 @current.add_child( result ) elsif ( line =~ /^XmlResult: (.*)/ ) result = XmlResult.new $1 @current.add_child( result ) elsif ( line =~ /^Contents/ ) @current.add_child( Contents.new ) elsif ( line =~ /^Version: (.*)/ ) version = Version.new $1 @current.add_child( version ) end end end |