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

match, parse

Methods inherited from Node

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

Constructor Details

#initialize(directive, block) ⇒ Yields

Returns a new instance of Yields.



28
29
30
31
32
# File 'lib/decode/comment/yields.rb', line 28

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

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



34
35
36
# File 'lib/decode/comment/yields.rb', line 34

def block
  @block
end

Class Method Details

.build(directive, match) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/decode/comment/yields.rb', line 18

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