Sha256: 8a44ae64a34d9c3675e1339a395991ca3336f9da11c2e64e50e123a0fcad0cda
Contents?: true
Size: 1.12 KB
Versions: 12
Compression:
Stored size: 1.12 KB
Contents
module RelatonBib class Edition # @return [String] edition attr_reader :content # @return [String, nil] number attr_reader :number # # Initialize edition. # # @param [String] content edition # @param [String, nil] number number # def initialize(content:, number: nil) @content = content @number = number end # # Render edition as XML. # # @param [Nokogiri::XML::Builder] builder XML builder # def to_xml(builder) node = builder.edition(content) node[:number] = number if number end # # Return edition as hash. # # @return [Hash] edition as hash. # def to_hash hash = { "content" => content } hash["number"] = number if number hash end # # Render edition as AsciiBib. # # @param [String] prefix prefix # # @return [String] edition as AsciiBib. # def to_asciibib(prefix = "") pref = prefix.empty? ? "edition" : "#{prefix}.edition" out = "#{pref}.content:: #{content}\n" out += "#{pref}.number:: #{number}\n" if number out end end end
Version data entries
12 entries across 12 versions & 1 rubygems