Parent

Methods

Files

Class/Module Index [+]

Quicksearch

SuperStruct

SuperStruct is an enhanced version of the Ruby Standard library {Struct}.

Compared with the original version, it provides the following additional features:

Public Class Methods

new(*args) click to toggle source

Overwrites the standard {Struct} initializer to add the ability to create an instance from a {Hash} of parameters.

@overload initialize({ Symbol => Object })

Initializes the object with a key/value hash.
@param [{ Symbol => Object }] values
@return [SuperStruct]

@overload initialize([ value1, value1, ... ])

Initializes the object with given values.
@param [Array] values
@return [SuperStruct]

@overload initialize(value1, value1, ...)

Initializes the object with given values.
@return [SuperStruct]

@yield self

@example

attributes = { :foo => 1, :bar => "baz" }
Struct.new(attributes)
# => #<Struct foo=1, bar="baz">
# File lib/whois/record/super_struct.rb, line 43
def initialize(*args)
  if args.first.is_a? Hash
    initialize_with_hash(args.first)
  elsif args.size == 0
    super
  else
    raise ArgumentError
  end
  yield(self) if block_given?
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.