Class: WSDSL::Response::Element::Attribute

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

Overview

Response element’s attribute class

Since:

  • 0.0.3

Direct Known Subclasses

MetaAttribute

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(o_params) ⇒ Attribute

Takes a Hash or an Array and extract the attribute name, type doc and extra options. If the passed objects is a Hash, the name will be extract from the first key and the type for the first value. An entry keyed by :doc will be used for the doc and the rest will go as extra options.

If an Array is passed, the elements will be ‘shifted’ in this order: name, type, doc, type

Parameters:

  • o_params (Hash, Array)

Since:

  • 0.0.3



427
428
429
430
431
432
433
434
435
436
437
438
439
# File 'lib/response.rb', line 427

def initialize(o_params)
  params = o_params.dup
  if params.is_a?(Hash)
    @name, @type = params.shift
    @doc  = params.delete(:doc) if params.has_key?(:doc)
    @opts = params
  elsif params.is_a?(Array)
    @name = params.shift
    @type = params.shift
    @doc  = params.shift
    @opts = params
  end
end

Instance Attribute Details

#docString (readonly)

Returns The documentation associated with this attribute.

Returns:

  • (String)

    The documentation associated with this attribute.

Since:

  • 0.0.3



407
408
409
# File 'lib/response.rb', line 407

def doc
  @doc
end

#nameString, #to_s (readonly) Also known as: value

Returns The attribute’s name.

Returns:

  • (String, #to_s)

    The attribute’s name.

Since:

  • 0.0.3



398
399
400
# File 'lib/response.rb', line 398

def name
  @name
end

#optsHash, ... (readonly)

Returns Could be a hash, nil or any object depending on how the attribute is created.

Returns:

  • (Hash, Nil, Object)

    Could be a hash, nil or any object depending on how the attribute is created.

See Also:

  • WSDSL::Response::Element::Attribute.{Attribute{Attribute#new}

Since:

  • 0.0.3



412
413
414
# File 'lib/response.rb', line 412

def opts
  @opts
end

#typeSymbol, ... (readonly)

Returns The attribute’s type such as boolean, string etc..

Returns:

  • (Symbol, String, #to_s)

    The attribute’s type such as boolean, string etc..

Since:

  • 0.0.3



403
404
405
# File 'lib/response.rb', line 403

def type
  @type
end