Sha256: 9114eeea570580098a484a5103f36c34805163002bd0c9f7a8a73b3738b64e3a
Contents?: true
Size: 1.27 KB
Versions: 3
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module DiverDown class Web class Metadata class SourceMetadata BLANK_MEMO = '' BLANK_RE = /\A\s*\z/ private_constant(:BLANK_MEMO) private_constant(:BLANK_RE) attr_reader :memo, :module # @param source_name [String] # NOTE: `module` is a reserved keyword in Ruby def initialize(memo: BLANK_MEMO, modulee: nil) @memo = memo @module = modulee end # @param memo [String] # @return [void] def memo=(memo) @memo = memo.strip end # @param modulee [String, nil] # @return [void] def module=(modulee) @module = if modulee.nil? || BLANK_RE.match?(modulee) nil else modulee.strip end end # @return [Boolean] def module? !@module.nil? end # @return [Hash] def to_h hash = {} hash[:memo] = memo unless memo == BLANK_MEMO hash[:module] = @module unless @module.nil? hash end private def by_source_name(source_name) @store[source_name] ||= {} end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems