Sha256: c6a1f333c8d3c7de25dfe2321905a37281e96222de9be7780fa9e9e67dfb99ec

Contents?: true

Size: 802 Bytes

Versions: 18

Compression:

Stored size: 802 Bytes

Contents

module RelatonBib
  class ICS
    # @return [String]
    attr_reader :code, :text

    # @param code [String]
    # @param text [String]
    def initialize(code:, text:)
      @code = code
      @text = text
    end

    # @param builder [Nokogiri::XML::Builder]
    def to_xml(builder)
      builder.ics do |b|
        b.code code
        b.text_ text
      end
    end

    # @return [Hash]
    def to_hash
      { "code" => code, "text" => text }
    end

    # @param prefix [String]
    # @param count [Integer] number of ics
    # @return [String]
    def to_asciibib(prefix = "", count = 1)
      pref = prefix.empty? ? "ics" : prefix + ".ics"
      out = count > 1 ? "#{pref}::\n" : ""
      out += "#{pref}.code:: #{code}\n"
      out += "#{pref}.text:: #{text}\n"
      out
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
relaton-bib-1.7.5 lib/relaton_bib/ics.rb
relaton-bib-1.7.4 lib/relaton_bib/ics.rb
relaton-bib-1.7.3 lib/relaton_bib/ics.rb
relaton-bib-1.7.2 lib/relaton_bib/ics.rb
relaton-bib-1.7.1 lib/relaton_bib/ics.rb
relaton-bib-1.7.0 lib/relaton_bib/ics.rb
relaton-bib-1.6.2 lib/relaton_bib/ics.rb
relaton-bib-1.6.1 lib/relaton_bib/ics.rb
relaton-bib-1.6.0 lib/relaton_bib/ics.rb
relaton-bib-1.6.pre1 lib/relaton_bib/ics.rb
relaton-bib-1.5.1 lib/relaton_bib/ics.rb
relaton-bib-1.5.0 lib/relaton_bib/ics.rb
relaton-bib-1.5.pre1 lib/relaton_bib/ics.rb
relaton-bib-1.5.pre lib/relaton_bib/ics.rb
relaton-bib-1.4.1 lib/relaton_bib/ics.rb
relaton-bib-1.4.0 lib/relaton_bib/ics.rb
relaton-bib-1.3.1 lib/relaton_bib/ics.rb
relaton-bib-1.3.0 lib/relaton_bib/ics.rb