Class: Decode::Comment::Attribute
- Defined in:
- lib/decode/comment/attribute.rb
Overview
Describes an attribute type.
-
‘@attribute [Integer] The person’s age.‘
Constant Summary collapse
- PATTERN =
/\A\[#{Tag.bracketed_content(:type)}\](\s+(?<details>.*?))?\Z/
Instance Attribute Summary collapse
- #The type of the attribute.(typeoftheattribute.) ⇒ Object readonly
-
#type ⇒ Object
readonly
Returns the value of attribute type.
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
-
.build(directive, match) ⇒ Object
Build an attribute from a directive and match.
Instance Method Summary collapse
-
#initialize(directive, type) ⇒ Attribute
constructor
Initialize a new attribute.
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 |
#type ⇒ Object (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 |