Module: Asciidoctor::Defmastership::Preprocessor::Helper
- Defined in:
- lib/asciidoctor-defmastership/preprocessor.rb
Overview
Helpers for Preprocessor class
Defined Under Namespace
Classes: DefinitionStringBuilder
Class Method Summary collapse
-
.explicit_version_str(explicit_version) ⇒ String
The replacement string for explicit version.
-
.labels_str(labels) ⇒ String
The replacement string for labels.
-
.valid_eref_url?(match) ⇒ Boolean
True if the match data includes a valid URL.
-
.variable_hash(match) ⇒ [Hash{String => Object}]
The hash corresponding to the variable setting.
Class Method Details
.explicit_version_str(explicit_version) ⇒ String
Returns the replacement string for explicit version.
229 230 231 |
# File 'lib/asciidoctor-defmastership/preprocessor.rb', line 229 def self.explicit_version_str(explicit_version) " [.version]#(#{explicit_version})#" if explicit_version end |
.labels_str(labels) ⇒ String
Returns the replacement string for labels.
217 218 219 220 221 222 223 224 225 |
# File 'lib/asciidoctor-defmastership/preprocessor.rb', line 217 def self.labels_str(labels) return unless labels labels_strings = labels.split(/\s*,\s*/).reduce([]) do |acc, label| acc << "[.tag.{tag-#{label}-color}]##{label}#" end " #{labels_strings.join(' ')}" end |
.valid_eref_url?(match) ⇒ Boolean
Returns true if the match data includes a valid URL.
211 212 213 |
# File 'lib/asciidoctor-defmastership/preprocessor.rb', line 211 def self.valid_eref_url?(match) match[:symb] == 'url' && !match[:value].eql?('none') end |
.variable_hash(match) ⇒ [Hash{String => Object}]
Returns the hash corresponding to the variable setting.
235 236 237 |
# File 'lib/asciidoctor-defmastership/preprocessor.rb', line 235 def self.variable_hash(match) { match[:varname] => match[:value] } end |