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\[#{Tag.bracketed_content(:type)}\](\s+(?<details>.*?))?\Z/

Instance Attribute Summary collapse

Attributes inherited from Tag

#The directive that generated the tag., #directive

Attributes inherited from Node

#The children of this node., #children

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tag

bracketed_content, match, parse

Methods inherited from Node

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

Constructor Details

#initialize(directive, type) ⇒ Attribute

Initialize a new attribute.



37
38
39
40
41
# File 'lib/decode/comment/attribute.rb', line 37

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

Instance Attribute Details

#The type of the attribute.(typeoftheattribute.) ⇒ Object (readonly)



44
# File 'lib/decode/comment/attribute.rb', line 44

attr :type

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Class Method Details

.build(directive, match) ⇒ Object

Build an attribute from a directive and match.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/decode/comment/attribute.rb', line 22

def self.build(directive, match)
	type = match[:type] or raise "Missing type in attribute match!"
	
	node = self.new(directive, type)
	
	if details = match[:details]
		node.add(Text.new(details))
	end
	
	return node
end