Class: Decode::Comment::Yields

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

Overview

Describes a block parameter.

  • ‘@yields {|person| … } If a block is given.`

Should contain nested parameters.

Constant Summary collapse

PATTERN =
/\A(?<block>{.*?})(\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, block) ⇒ Yields

Returns a new instance of Yields.



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

def initialize(directive, block)
	super(directive)
	
	@block = block
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



49
50
51
# File 'lib/decode/comment/yields.rb', line 49

def block
  @block
end

Class Method Details

.build(directive, match) ⇒ Object



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

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