Class: Decode::Comment::Attribute

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

Overview

Describes an attribute type.

  • ‘@attribute [Integer] The person’s age.‘

Direct Known Subclasses

Raises, Returns, Throws

Constant Summary collapse

PATTERN =
/\A\[(?<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, type) ⇒ Attribute

Returns a new instance of Attribute.



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

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

Instance Attribute Details

#typeObject (readonly)

The type of the attribute.



50
51
52
# File 'lib/decode/comment/attribute.rb', line 50

def type
  @type
end

Class Method Details

.build(directive, match) ⇒ Object



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

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