Class: DeepConnect::MethodSpec::ParamSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/deep-connect/class-spec-space.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ParamSpec

Returns a new instance of ParamSpec.



376
377
378
379
380
# File 'lib/deep-connect/class-spec-space.rb', line 376

def initialize(name)
	@type = name

	@mult = nil
end

Instance Attribute Details

#multObject Also known as: mult?

Returns the value of attribute mult.



383
384
385
# File 'lib/deep-connect/class-spec-space.rb', line 383

def mult
  @mult
end

#typeObject (readonly)

Returns the value of attribute type.



382
383
384
# File 'lib/deep-connect/class-spec-space.rb', line 382

def type
  @type
end

Class Method Details

.identifier(token, *opts) ⇒ Object



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
# File 'lib/deep-connect/class-spec-space.rb', line 342

def self.identifier(token, *opts)
	case token
	when String
	  name = token
	  if /^\*(.*)/ =~ token
	    name = $1
	    opts.push :mult
	  end
	when Token
	  name = token.name
	end

	klass = Name2ParamSpec[name]
	unless klass
	  MethodSpec.Raise UnrecognizedError, name
	end
	pspec = klass.new(name)
	if opts.include?(:mult)
	  pspec.mult = true
	end
	pspec
end

.param_specs(string_ary) ⇒ Object



365
366
367
368
369
370
371
372
373
374
# File 'lib/deep-connect/class-spec-space.rb', line 365

def self.param_specs(string_ary)
	case string_ary
	when nil
	  nil
	when Array
	  string_ary.collect{|e| ParamSpec.identifier(e)}
	else
	  [ParamSpec.identifier(string_ary)]
	end
end

Instance Method Details

#to_sObject



386
387
388
389
390
391
392
# File 'lib/deep-connect/class-spec-space.rb', line 386

def to_s
	if mult
	  "*"+@type
	else
	  @type
	end
end