Sha256: 656929115c3818be86dad5e22676c3c4cfaaf4e5027727fdd15e2a700285729e

Contents?: true

Size: 832 Bytes

Versions: 8

Compression:

Stored size: 832 Bytes

Contents

# frozen_string_literal: true

# Released under the MIT License.
# Copyright, 2020, by Samuel Williams.

require_relative 'tag'

module Decode
	module Comment
		# Describes a named method parameter.
		#
		# - `@parameter age [Float] The users age.`
		#
		class Parameter < Tag
			PATTERN = /\A(?<name>.*?)\s+\[(?<type>.*?)\](\s+(?<details>.*?))?\Z/
			
			def self.build(directive, match)
				node = self.new(directive, match[:name], match[:type])
				
				if details = match[:details]
					node.add(Text.new(details))
				end
				
				return node
			end
			
			def initialize(directive, name, type)
				super(directive)
				
				@name = name
				@type = type
			end
			
			# The name of the parameter.
			# @attribute [String]
			attr :name
			
			# The type of the attribute.
			# @attribute [String]
			attr :type
		end
	end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
decode-0.21.3 lib/decode/comment/parameter.rb
decode-0.21.2 lib/decode/comment/parameter.rb
decode-0.21.1 lib/decode/comment/parameter.rb
decode-0.21.0 lib/decode/comment/parameter.rb
decode-0.20.2 lib/decode/comment/parameter.rb
decode-0.20.1 lib/decode/comment/parameter.rb
decode-0.20.0 lib/decode/comment/parameter.rb
decode-0.19.0 lib/decode/comment/parameter.rb