Sha256: 72e9714aa57d7724739518e1c43671b12c828019767cc905ef343d6cf0b7673a
Contents?: true
Size: 1.18 KB
Versions: 12
Compression:
Stored size: 1.18 KB
Contents
module RelatonBib class DocumentType attr_reader :type, :abbreviation # # Initialize a DocumentType. # # @param [String] type document type # @param [String, nil] abbreviation type abbreviation # def initialize(type:, abbreviation: nil) @type = type @abbreviation = abbreviation end # # Build XML representation of the document type. # # @param [Nokogiri::XML::Builder] builder XML builder # def to_xml(builder) xml = builder.doctype @type xml[:abbreviation] = @abbreviation if @abbreviation end # # Hash representation of the document type. # # @return [Hash] # def to_hash hash = { "type" => @type } hash["abbreviation"] = @abbreviation if @abbreviation hash end # # Asciibib representation of the document type. # # @param [String] prefix prefix # # @return [String] AsciiBib representation # def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : "#{prefix}." pref += "doctype." out = "#{pref}type:: #{@type}\n" out += "#{pref}abbreviation:: #{@abbreviation}\n" if @abbreviation out end end end
Version data entries
12 entries across 12 versions & 1 rubygems