Class: Decode::Comment::Constant
- Defined in:
- lib/decode/comment/constant.rb
Overview
Represents a constant type declaration.
-
‘@constant [Regexp] Pattern for matching parameters.`
Constant Summary collapse
- PATTERN =
/\A\[#{Tag.bracketed_content(:type)}\](\s+(?<details>.*?))?\Z/
Instance Attribute Summary collapse
- #The type of the constant.(typeoftheconstant.) ⇒ 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 a constant from a directive and regex match.
Instance Method Summary collapse
-
#initialize(directive, type) ⇒ Constant
constructor
Initialize a new constant.
Methods inherited from Tag
bracketed_content, match, parse
Methods inherited from Node
#add, #children?, #each, #filter, #text, #traverse
Constructor Details
#initialize(directive, type) ⇒ Constant
Initialize a new constant.
38 39 40 41 |
# File 'lib/decode/comment/constant.rb', line 38 def initialize(directive, type) super(directive) @type = type end |
Instance Attribute Details
#The type of the constant.(typeoftheconstant.) ⇒ Object (readonly)
44 |
# File 'lib/decode/comment/constant.rb', line 44 attr :type |
#type ⇒ Object (readonly)
Returns the value of attribute type.
44 45 46 |
# File 'lib/decode/comment/constant.rb', line 44 def type @type end |
Class Method Details
.build(directive, match) ⇒ Object
Build a constant from a directive and regex match.
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/decode/comment/constant.rb', line 23 def self.build(directive, match) type = match[:type] or raise "Missing type in constant match!" node = self.new(directive, type) if details = match[:details] node.add(Text.new(details)) end return node end |