Class: Decode::Comment::Parameter

Inherits:
Tag
  • Object
show all
Defined in:
lib/decode/comment/parameter.rb

Overview

Describes a named method parameter.

  • ‘@parameter age [Float] The users age.`

Constant Summary collapse

PATTERN =
/\A(?<name>.*?)\s+\[(?<type>.*?)\](\s+(?<details>.*?))?\Z/

Instance Attribute Summary collapse

Attributes inherited from Tag

#directive

Attributes inherited from Node

#children

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tag

parse

Methods inherited from Node

#add, #children?, #each, #text, #traverse

Constructor Details

#initialize(directive, name, type) ⇒ Parameter

Returns a new instance of Parameter.



42
43
44
45
46
47
# File 'lib/decode/comment/parameter.rb', line 42

def initialize(directive, name, type)
	super(directive)
	
	@name = name
	@type = type
end

Instance Attribute Details

#detailsObject (readonly)

The details associated with the tag.



59
60
61
# File 'lib/decode/comment/parameter.rb', line 59

def details
  @details
end

#nameObject (readonly)

The name of the parameter.



51
52
53
# File 'lib/decode/comment/parameter.rb', line 51

def name
  @name
end

#typeObject (readonly)

The type of the attribute.



55
56
57
# File 'lib/decode/comment/parameter.rb', line 55

def type
  @type
end

Class Method Details

.build(directive, match) ⇒ Object



32
33
34
35
36
37
38
39
40
# File 'lib/decode/comment/parameter.rb', line 32

def self.build(directive, match)
	node = self.new(directive, match[:name], match[:type])
	
	if details = match[:details]
		node.add(Text.new(details))
	end
	
	return node
end